- jMonkeyEngine 3.0 Beginner’s Guide
- Ruth Kusterer
- 260字
- 2021-08-13 17:02:12
Time for action – pick a brick (using the mouse pointer)
Aiming fixed crosshairs is one way to pick objects in the scene. Another option is to make the mouse pointer visible, and allow free clicks.
- Make a copy of the previous exercise,
TargetPickCenter.java
. You can keep the code that handles the mouse click actions and the key press actions for inspiration. - Rename the copy of the class to
TargetPickCursor.java
. Remember to also refactor the first line of themain()
method to the following:TargetPickCursor app = new TargetPickCursor();
- Keep the
myBox()
method, the constants, theanalogListener
object, and the two cubes. Remove theattachCenterMark()
method, and theAnalogListener
object implementation. - By default, the mouse pointer is hidden. To make it visible, add the following to the
simpleInitApp()
method:flyCam.setDragToRotate(true); inputManager.setCursorVisible(true);
Run TargetPickCursor
to see the intermediate result.
What just happened?
Again, you see the red cube above the blue cube. When you move the mouse, you notice that the pointer is a visible arrow now. But you also notice something else; earlier, the view rotated when you moved the mouse to the sides. This feature is part of the default camera behavior and is called mouse look, or free look. Mouse look does not get along with a visible mouse pointer. You can use the mouse either for navigating, or for pointing and clicking. Both at the same time is quite confusing for the player.
You deactivated mouse look when you set flyCam.setDragToRotate(true)
;. To rotate the camera and look around now, keep the left mouse button pressed while moving.
- CMDB分步構(gòu)建指南
- Flink SQL與DataStream入門、進(jìn)階與實(shí)戰(zhàn)
- Android 7編程入門經(jīng)典:使用Android Studio 2(第4版)
- UML+OOPC嵌入式C語言開發(fā)精講
- Scratch 3.0少兒編程與邏輯思維訓(xùn)練
- Xamarin.Forms Projects
- Python 3破冰人工智能:從入門到實(shí)戰(zhàn)
- EPLAN實(shí)戰(zhàn)設(shè)計(jì)
- Building Serverless Applications with Python
- SQL Server 2016數(shù)據(jù)庫應(yīng)用與開發(fā)
- Learning Vaadin 7(Second Edition)
- 深入理解Elasticsearch(原書第3版)
- Learning Hadoop 2
- Android應(yīng)用開發(fā)實(shí)戰(zhàn)
- 物聯(lián)網(wǎng)系統(tǒng)架構(gòu)設(shè)計(jì)與邊緣計(jì)算(原書第2版)