• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Cursor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.lwjgl.input.Cursor的典型用法代码示例。如果您正苦于以下问题:Java Cursor类的具体用法?Java Cursor怎么用?Java Cursor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Cursor类属于org.lwjgl.input包,在下文中一共展示了Cursor类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setMouseCursor

import org.lwjgl.input.Cursor; //导入依赖的package包/类
/**
  * {@inheritDoc}
  */
 public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
     try {
        Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
        Graphics g = temp.getGraphics();
        
        ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
        g.drawImage(image.getFlippedCopy(false, true), 0, 0);
        g.flush();
        g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
        
        Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
        Mouse.setNativeCursor(cursor);
     } catch (Throwable e) {
        Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
     }
  }
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:21,代码来源:AppletGameContainer.java


示例2: setMouseCursor

import org.lwjgl.input.Cursor; //导入依赖的package包/类
/**
 * @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
 */
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
	try {
		Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
		Graphics g = temp.getGraphics();
		
		ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
		g.drawImage(image.getFlippedCopy(false, true), 0, 0);
		g.flush();
		g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
		
		Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
		Mouse.setNativeCursor(cursor);
	} catch (Throwable e) {
		Log.error("Failed to load and apply cursor.", e);
		throw new SlickException("Failed to set mouse cursor", e);
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:21,代码来源:AppGameContainer.java


示例3: getCursor

import org.lwjgl.input.Cursor; //导入依赖的package包/类
/**
 * Get a cursor based on a set of image data
 * 
 * @param buf The image data (stored in RGBA) to load the cursor from
 * @param x The x-coordinate of the cursor hotspot (left -> right)
 * @param y The y-coordinate of the cursor hotspot (bottom -> top)
 * @param width The width of the image data provided
 * @param height The height of the image data provided
 * @return The create cursor
 * @throws IOException Indicates a failure to load the image
 * @throws LWJGLException Indicates a failure to create the hardware cursor
 */
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
	for (int i=0;i<buf.limit();i+=4) {
		byte red = buf.get(i);
		byte green = buf.get(i+1);
		byte blue = buf.get(i+2);
		byte alpha = buf.get(i+3);
		
		buf.put(i+2, red);
		buf.put(i+1, green);
		buf.put(i, blue);
		buf.put(i+3, alpha);
	}
	
	try {
		int yspot = height - y - 1;
		if (yspot < 0) {
			yspot = 0;
		}
		return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
	} catch (Throwable e) {
		Log.info("Chances are you cursor is too small for this platform");
		throw new LWJGLException(e);
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:37,代码来源:CursorLoader.java


示例4: setMouseCursor

import org.lwjgl.input.Cursor; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
    try {
       Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
       Graphics g = temp.getGraphics();
       
       ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
       g.drawImage(image.getFlippedCopy(false, true), 0, 0);
       g.flush();
       g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
       
       Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
       Mouse.setNativeCursor(cursor);
    } catch (Exception e) {
       Log.error("Failed to load and apply cursor.", e);
    }
 }
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:20,代码来源:AppletGameContainer.java


示例5: setMouseCursor

import org.lwjgl.input.Cursor; //导入依赖的package包/类
/**
 * @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
 */
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
	try {
		Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
		Graphics g = temp.getGraphics();
		
		ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
		g.drawImage(image.getFlippedCopy(false, true), 0, 0);
		g.flush();
		g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
		
		Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
		Mouse.setNativeCursor(cursor);
	} catch (Exception e) {
		Log.error("Failed to load and apply cursor.", e);
	}
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:20,代码来源:AppGameContainer.java


示例6: create

import org.lwjgl.input.Cursor; //导入依赖的package包/类
@Override
    public void create() {        
        ClientMain.logSystemSpecs(console);
        ClientMain.logVideoSpecs(console);
        
        Art.load();
        Sounds.init(config);
                

        this.uiManager = new UserInterfaceManager();
        seventh.client.gfx.Cursor cursor = this.uiManager.getCursor();
        float sensitivity = config.getMouseSensitivity();
        if(sensitivity > 0) {
            cursor.setMouseSensitivity(sensitivity);
        }
        
        Gdx.input.setInputProcessor(this.inputs);
//        Gdx.input.setCursorCatched(true);
        
        initControllers();        
        videoReload();        
        
        this.menuScreen = new MenuScreen(this);
        goToMenuScreen();
    }
 
开发者ID:tonysparks,项目名称:seventh,代码行数:26,代码来源:SeventhGame.java


示例7: setMouseCursor

import org.lwjgl.input.Cursor; //导入依赖的package包/类
/**
 * @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
 */
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
	try {
		Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
		Graphics g = temp.getGraphics();
		
		ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
		g.drawImage(image.getFlippedCopy(false, true), 0, 0);
		g.flush();
		g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
		
		Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
		Mouse.setNativeCursor(cursor);
	} catch (Throwable e) {
		Log.error("Failed to load and apply cursor.", e);
		throw new SlickException("Failed to set mouse cursor", e);
	}
}
 
开发者ID:nguillaumin,项目名称:slick2d-maven,代码行数:21,代码来源:AppGameContainer.java



注:本文中的org.lwjgl.input.Cursor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MenuDragMouseListener类代码示例发布时间:2022-05-21
下一篇:
Java ResolverStyle类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap