|
@@ -1,6 +1,6 @@
|
|
= SimpleApplication
|
|
= SimpleApplication
|
|
-:author:
|
|
|
|
-:revnumber:
|
|
|
|
|
|
+:author:
|
|
|
|
+:revnumber:
|
|
:revdate: 2016/03/17 20:48
|
|
:revdate: 2016/03/17 20:48
|
|
:keywords: display, basegame, documentation, intro, intermediate, init, input, game, loop, rootnode, application, simpleapplication
|
|
:keywords: display, basegame, documentation, intro, intermediate, init, input, game, loop, rootnode, application, simpleapplication
|
|
:relfileprefix: ../../
|
|
:relfileprefix: ../../
|
|
@@ -8,9 +8,9 @@
|
|
ifdef::env-github,env-browser[:outfilesuffix: .adoc]
|
|
ifdef::env-github,env-browser[:outfilesuffix: .adoc]
|
|
|
|
|
|
|
|
|
|
-The base class of the jMonkeyEngine3 is `com.jme3.app.SimpleApplication`. Your first game's Main class extends SimpleApplication directly. When you feel confident you understand the features, you will typically extend SimpleApplication to create a custom base class for the type of games that you want to develop.
|
|
|
|
|
|
+The base class of the jMonkeyEngine3 is `com.jme3.app.SimpleApplication`. Your first game's Main class extends SimpleApplication directly. When you feel confident you understand the features, you will typically extend SimpleApplication to create a custom base class for the type of games that you want to develop.
|
|
|
|
|
|
-SimpleApplication gives you access to standard game features, such as a scene graph (rootNode), an asset manager, a user interface (guiNode), input manager, audio manager, a physics simulation, and a fly-by camera. You call app.start() and app.stop() on your game instance to start or quit the application.
|
|
|
|
|
|
+SimpleApplication gives you access to standard game features, such as a scene graph (rootNode), an asset manager, a user interface (guiNode), input manager, audio manager, a physics simulation, and a fly-by camera. You call app.start() and app.stop() on your game instance to start or quit the application.
|
|
|
|
|
|
|
|
|
|
[IMPORTANT]
|
|
[IMPORTANT]
|
|
@@ -78,15 +78,15 @@ a|The default <<jme3/advanced/camera#,camera>> provides perspective projection,
|
|
a|assetManager +
|
|
a|assetManager +
|
|
getAssetManager()
|
|
getAssetManager()
|
|
a|An object that manages paths for loading models, textures, materials, sounds, etc. +
|
|
a|An object that manages paths for loading models, textures, materials, sounds, etc. +
|
|
-By default the <<jme3/advanced/asset_manager#,Asset Manager>> paths are relative to your project's root directory.
|
|
|
|
|
|
+By default the <<jme3/advanced/asset_manager#,Asset Manager>> paths are relative to your project's root directory.
|
|
|
|
|
|
a|audioRenderer +
|
|
a|audioRenderer +
|
|
getAudioRenderer()
|
|
getAudioRenderer()
|
|
-a|This object gives you access to the jME3 <<jme3/advanced/audio#,audio>> system.
|
|
|
|
|
|
+a|This object gives you access to the jME3 <<jme3/advanced/audio#,audio>> system.
|
|
|
|
|
|
a|listener +
|
|
a|listener +
|
|
getListener()
|
|
getListener()
|
|
-a|This object represents the user's ear for the jME3 <<jme3/advanced/audio#,audio>> system.
|
|
|
|
|
|
+a|This object represents the user's ear for the jME3 <<jme3/advanced/audio#,audio>> system.
|
|
|
|
|
|
a|inputManager +
|
|
a|inputManager +
|
|
getInputManager()
|
|
getInputManager()
|
|
@@ -104,10 +104,10 @@ a|Application methods
|
|
a|Purpose
|
|
a|Purpose
|
|
|
|
|
|
a|setPauseOnLostFocus(true)
|
|
a|setPauseOnLostFocus(true)
|
|
-a|Set this boolean whether the game loop should stop running when ever the window loses focus (typical for single-player game). Set this to false for real-time and multi-player games that keep running.
|
|
|
|
|
|
+a|Set this boolean whether the game loop should stop running when ever the window loses focus (typical for single-player game). Set this to false for real-time and multi-player games that keep running.
|
|
|
|
|
|
a|start()
|
|
a|start()
|
|
-a|Call this method to start a jME3 game. By default this opens a new jME3 window, initializes the scene, and starts the event loop.
|
|
|
|
|
|
+a|Call this method to start a jME3 game. By default this opens a new jME3 window, initializes the scene, and starts the event loop.
|
|
|
|
|
|
a|restart()
|
|
a|restart()
|
|
a|Loads modified <<jme3/intermediate/appsettings#,AppSettings>> into the current application context.
|
|
a|Loads modified <<jme3/intermediate/appsettings#,AppSettings>> into the current application context.
|
|
@@ -148,7 +148,7 @@ a|Low-level and high-level rendering interface. Mostly used internally.
|
|
|
|
|
|
a|guiViewPort +
|
|
a|guiViewPort +
|
|
getGuiViewPort()
|
|
getGuiViewPort()
|
|
-a|The view object for the orthogonal +++<abbr title="Graphical User Interface">GUI</abbr>+++ view. Only used internally for <<jme3/advanced/hud#,HUD>>s.
|
|
|
|
|
|
+a|The view object for the orthogonal +++<abbr title="Graphical User Interface">GUI</abbr>+++ view. Only used internally for <<jme3/advanced/hud#,HUD>>s.
|
|
|
|
|
|
a|timer
|
|
a|timer
|
|
a|An internal update loop timer, don't use. See `tpf` in `simpleUpdate()` below to learn about timers.
|
|
a|An internal update loop timer, don't use. See `tpf` in `simpleUpdate()` below to learn about timers.
|
|
@@ -165,7 +165,7 @@ The com.jme3.app.SimpleApplication class extends the generic com.jme3.app.Applic
|
|
|
|
|
|
* First-person (fly-by) camera
|
|
* First-person (fly-by) camera
|
|
* Scene graph that manages your models in the rendered 3D scene.
|
|
* Scene graph that manages your models in the rendered 3D scene.
|
|
-* Useful default input mappings (details below.)
|
|
|
|
|
|
+* Useful default input mappings (details below.)
|
|
|
|
|
|
Additional to the functionality that Application brings, SimpleApplication offers the following methods and fields that can be used, for example, inside the `simpleInitApp()` method:
|
|
Additional to the functionality that Application brings, SimpleApplication offers the following methods and fields that can be used, for example, inside the `simpleInitApp()` method:
|
|
[cols="25,75", options="header"]
|
|
[cols="25,75", options="header"]
|
|
@@ -203,7 +203,13 @@ a|setDisplayFps(false);
|
|
a|A default SimpleApplication displays the framerate (frames per second) on the screen. You can choose to deactivate the FPS display using this command.
|
|
a|A default SimpleApplication displays the framerate (frames per second) on the screen. You can choose to deactivate the FPS display using this command.
|
|
|
|
|
|
a|setDisplayStatView(false);
|
|
a|setDisplayStatView(false);
|
|
-a|A default SimpleApplication displays mesh statistics on the screen using the com.jme3.app.StatsView class. The information is valuable during the development and debugging phase, but for the release, you should hide the statistics HUD.
|
|
|
|
|
|
+a|A default SimpleApplication displays mesh statistics on the screen using the com.jme3.app.StatsView class. The information is valuable during the development and debugging phase, but for the release, you should hide the statistics HUD. +
|
|
|
|
+*pass:[*]Note:* There is a dark quad behind the stats. Each letter displayed in the stats is a quad. Each quad has 4 vertexes and 2 triangles. +
|
|
|
|
+
|
|
|
|
+456/2 = 228 +
|
|
|
|
+912/4 = 228
|
|
|
|
+
|
|
|
|
+This means if you display stats, there will be 456 triangles and 912 vertices showing in the stats view in addition to anything you add yourself.
|
|
|
|
|
|
|===
|
|
|===
|
|
[cols="40,60", options="header"]
|
|
[cols="40,60", options="header"]
|
|
@@ -217,7 +223,7 @@ a|Override this method to initialize the game scene. Here you load and create ob
|
|
|
|
|
|
a|public void simpleUpdate(float tpf)
|
|
a|public void simpleUpdate(float tpf)
|
|
a|Override this method to hook into the <<jme3/advanced/update_loop#,update loop>>, all code you put here is repeated in a loop. Use this loop to poll the current game state and respond to changes, or to let the game mechanics generate encounters and initiate state changes. Use the float `tpf` as a factor to time actions relative to the _time per frame_ in seconds: `tpf` is large on slow PCs, and small on fast PCs. +
|
|
a|Override this method to hook into the <<jme3/advanced/update_loop#,update loop>>, all code you put here is repeated in a loop. Use this loop to poll the current game state and respond to changes, or to let the game mechanics generate encounters and initiate state changes. Use the float `tpf` as a factor to time actions relative to the _time per frame_ in seconds: `tpf` is large on slow PCs, and small on fast PCs. +
|
|
-For more info on how to hook into the <<jme3/advanced/update_loop#,update loop>>, see <<jme3/advanced/application_states#,Application States>> and <<jme3/advanced/custom_controls#,Custom Controls>>.
|
|
|
|
|
|
+For more info on how to hook into the <<jme3/advanced/update_loop#,update loop>>, see <<jme3/advanced/application_states#,Application States>> and <<jme3/advanced/custom_controls#,Custom Controls>>.
|
|
|
|
|
|
a|public void simpleRender(RenderManager rm)
|
|
a|public void simpleRender(RenderManager rm)
|
|
a|*Optional:* Advanced developers can override this method if the need to modify the frameBuffer and scene graph directly.
|
|
a|*Optional:* Advanced developers can override this method if the need to modify the frameBuffer and scene graph directly.
|
|
@@ -310,7 +316,7 @@ By default, a SimpleApplication displays Statistics (`new StatsAppState()`), has
|
|
|
|
|
|
The following example shows how you can remove one of the default AppStates, in this case, the FlyCamAppState:
|
|
The following example shows how you can remove one of the default AppStates, in this case, the FlyCamAppState:
|
|
|
|
|
|
-* Either, in your application's contructor, you create the SimpleApplication with only the AppStates you want to keep:
|
|
|
|
|
|
+* Either, in your application's contructor, you create the SimpleApplication with only the AppStates you want to keep:
|
|
[source,java]
|
|
[source,java]
|
|
----
|
|
----
|
|
public MyAppliction() {
|
|
public MyAppliction() {
|
|
@@ -318,11 +324,10 @@ public MyAppliction() {
|
|
}
|
|
}
|
|
----
|
|
----
|
|
|
|
|
|
-* Or, in the `simpleInitApp()` method, you remove the ones you do not want to keep:
|
|
|
|
|
|
+* Or, in the `simpleInitApp()` method, you remove the ones you do not want to keep:
|
|
[source,java]
|
|
[source,java]
|
|
----
|
|
----
|
|
public void simpleInitApp() {
|
|
public void simpleInitApp() {
|
|
stateManager.detach( stateManager.getState(FlyCamAppState.class));
|
|
stateManager.detach( stateManager.getState(FlyCamAppState.class));
|
|
...
|
|
...
|
|
----
|
|
----
|
|
-
|
|
|