博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
libgdx 3D 瞄准星和隐藏鼠标
阅读量:7242 次
发布时间:2019-06-29

本文共 2058 字,大约阅读时间需要 6 分钟。

1. 瞄准星

1 /**画瞄准星*/ 2     private void drawSight(){ 3         debugRenderer.begin(ShapeRenderer.ShapeType.Line); 4         float w = 50; 5         float h = 40; 6         Rectangle rect = new Rectangle((Gdx.graphics.getWidth()-w)/2, (Gdx.graphics.getHeight()-h)/2, w, h); 7         debugRenderer.setColor(new Color(0, 1, 0, 1)); 8         debugRenderer.rect(rect.x, rect.y, rect.width, rect.height); 9 10         //画十字线11         debugRenderer.line((Gdx.graphics.getWidth()-2*w)/2,Gdx.graphics.getHeight()/2,(Gdx.graphics.getWidth()+2*w)/2,Gdx.graphics.getHeight()/2);12         debugRenderer.line(Gdx.graphics.getWidth()/2,(Gdx.graphics.getHeight()-2*h)/2,Gdx.graphics.getWidth()/2,(Gdx.graphics.getHeight()+2*h)/2);13         debugRenderer.end();14     }
debugRenderer = new ShapeRenderer();debugRenderer.setProjectionMatrix(stage.getCamera().combined);

 

其中stage是ui用的,比如显示个FPS之类的,或者其他用户界面

效果图:

 

 

2. 隐藏鼠标指针

1 /**隐藏鼠标指针*/ 2     private void hideCursor(){ 3         if (Gdx.app.getType() != Application.ApplicationType.Desktop) 4             return; 5         if (emptyCursor == null) { 6             if (Mouse.isCreated()) { 7                 int min = org.lwjgl.input.Cursor.getMinCursorSize(); 8                 IntBuffer tmp = BufferUtils.newIntBuffer(min * min); 9                 try {10                     emptyCursor = new org.lwjgl.input.Cursor(min, min, min / 2, min / 2, 1, tmp, null);11                 } catch (LWJGLException e) {12                     e.printStackTrace();13                 }14             } else {15                 System.out.println("Could not create empty cursor before Mouse object is created");16             }17         }18         if (Mouse.isInsideWindow())19             try {20                 Mouse.setNativeCursor(false ? null : emptyCursor);21             } catch (LWJGLException e) {22                 e.printStackTrace();23             }24     }
private org.lwjgl.input.Cursor emptyCursor;

我抄来的,详情见:https://gist.github.com/mattdesl/4255483 

 

 

//TODO 准星在调整窗口大小后有问题。

 

转载于:https://www.cnblogs.com/hanhongmin/p/3868673.html

你可能感兴趣的文章
项目总结24:海关179号(实时获取电商平台企业支付相关原始数据)开发流程和相关资料...
查看>>
[hdu6437]Problem L. Videos
查看>>
代价函数~ML
查看>>
关键字过虑实现的思路及Aho–Corasick高效字符串匹配算法应用
查看>>
php api 接口
查看>>
复利计算4.0-单元测试
查看>>
python pandas/numpy
查看>>
Javascript与ECMAScript
查看>>
ipad
查看>>
Spring RPC 入门学习(1)-HelloWorld入门
查看>>
Codeforces 1076 E - Vasya and a Tree
查看>>
Erlang使用ProtoBuffer
查看>>
集中式(SVN)和分布式(Git)版本控制系统的简单比较
查看>>
Chapter 11. WinForm-文件及文件夹操作
查看>>
索引及基应用
查看>>
[BZOJ 4800][Ceoi2015]Ice Hockey World Championship(Meet-in-the-Middle)
查看>>
python 数据加密以及生成token和token验证
查看>>
学Js之prototype
查看>>
CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14
查看>>
Apache Storm
查看>>