JME中级手册,SimpleApplcation

SimpleApplication Class

The com.jme3.app.SimpleApplication class extends the com.jme3.app.Application class to provide default functionality like a first-person (fly-by) camera, and a scenegraph with a rootNode that is updated and rendered regularly. By default, a SimpleApplication displays statistics (such as frames per second) on-screen, using the com.jme3.app.StatsView class. You deactivate the statistics HUD by calling app.setDisplayFps(false); app.setDisplayStatView(false);. Some input keys are pre-configured by default: You quit the application by pressing the Escape key, and you can control the camera using the mouse, the arrow keys, and WASD keys. (More details below.) Additional to what Application offers, SimpleApplication offers:

SimpleApplication FeaturePurpose
getRootNode() 
rootNode
The root node of the scene graph. A Spatial that you attach to the rootNode appears in the 3D scene.
(场景中的根节点)
getGuiNode() 
guiNode
Attach flat GUI elements (such as HUD images and text) to this orthogonal GUI node.(GUI节点)
loadStatsView() Call this method to print live statistic information to the screen, such as current frames-per-second and triangles/vertices counts. Use this info during the development phase.
(调用这个方法再屏幕上打印状态信息。使用在开发阶段)
setDisplayFps(false); 
setDisplayStatView(false);
Call these method to remove the statistic information from the screen, for example, before releases.
(调用这些方法屏蔽状态信息)
getFlyByCamera() 
flyCam
The default fly-by camera object, controlled by the WASD and arrow keys.(默认飞行相机对象,由WASD和方向键控制)
setShowSettings(true) Whether the user should be presented with a splashscreen and display settings dialog when starting the game. Set this boolean before calling start() on the SimpleApplication.
(启动设置对话框用)
simpleInitApp() Override this method to initialize the game scene. Here you load and create objects, attach Spatials to the rootNode, and bring everything in its starts position.
(附加Spatials到根节点,初始化方法)
simpleUpdate(float tpf) Override this method to have access to the main event loop. Use this loop to poll the current game state and respond to changes, or to initiate state changes and to generate encounters. For advanced info how to hook into the update loop, see also Application States and Custom Controls.(重载此方法进入主循环制定控制和应用状态)
simpleRender() Optionally, override this method to do advanced modifications to the frameBuffer and scene graph.(场景中重载此方法对帧缓存在场景中做高级修改)

Input Defaults

The following default actions are available for a running game:

KeyAction
KEY_ESCAPE Quits the game by calling app.stop()
KEY_C Prints camera position, rotation, and direction
KEY_M Prints memory usage stats

If useInput() is true, the default Flyby Cam is active. Then the following so-called "WASD" inputs are additionally available:

Camera MotionKey or Mouse Input
Move Forward KEY_W
Move Left (Strafe) KEY_A
Move Backward KEY_S
Move Right (Strafe) KEY_D
Move Vertical Upward KEY_Q
Move Vertical Downward KEY_Z
Rotate Left KEY_LEFT, or move mouse horizontally left (-x)
Rotate Right KEY_RIGHT, or move mouse horizontally right (+x)
Rotate Up KEY_UP, or move mouse vertically forward (+y)
Rotate Down KEY_DOWN, or move mouse vertically backward (-y)
Zoom In Scroll mouse wheel backward
Zoom Out Scroll mouse wheel forward
Rotate drag Hold left mouse button and move

posted on 2011-08-12 11:40  苏桓(osbert)  阅读(494)  评论(0编辑  收藏  举报

导航