您的位置:首页 > 移动开发

JME中级手册,SimpleApplcation

2011-08-12 11:40 267 查看
[align=center][/align]

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_ESCAPEQuits the game by calling
app.stop()
KEY_CPrints camera position, rotation, and direction
KEY_MPrints 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 ForwardKEY_W
Move Left (Strafe)KEY_A
Move BackwardKEY_S
Move Right (Strafe)KEY_D
Move Vertical UpwardKEY_Q
Move Vertical DownwardKEY_Z
Rotate LeftKEY_LEFT, or move mouse horizontally left (-x)
Rotate RightKEY_RIGHT, or move mouse horizontally right (+x)
Rotate UpKEY_UP, or move mouse vertically forward (+y)
Rotate DownKEY_DOWN, or move mouse vertically backward (-y)
Zoom InScroll mouse wheel backward
Zoom OutScroll mouse wheel forward
Rotate dragHold left mouse button and move
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: