|
@@ -103,61 +103,61 @@ stateDetached(asm)</p></div></div></td><td class="tableblock halign-left valign-
|
|
|
}</code></pre></div></div></div>
|
|
|
<div class="sect2"><h3 id="baseappstate">BaseAppState</h3><div class="paragraph"><p>A new <a href="http://javadoc.jmonkeyengine.org/com/jme3/app/state/BaseAppState.html">BaseAppState</a> class was introduced as part of the <a href="https://hub.jmonkeyengine.org/t/jmonkeyengine-3-1-alpha-4-released/35478">updates</a> being made to the AppState interface. AbstractAppState is the most minimal of the minimal implementations of the AppState interface. You essentially still need to do everything yourself, including getting the funky enable/disable/initialized/terminate logic right. Now you just extend BaseAppState and you get onEnable() and onDisable() already worked out for you.</p></div>
|
|
|
<div class="paragraph"><p>Notable BaseAppState changes are as follows:</p></div>
|
|
|
-<div class="ulist"><ul><li><p>You no longer need to call super.initialize(stateManager, app) because it is now called by BaseAppState upon initialization for you.</p></li><li><p>You no longer have to cast SimpleApplication to have access to AssetManager, AppStateManager, and you can even get a State directly. The getters getApplication(), getAssetManager(), getState(type) and thier methods are available to you immediately. However, you still have to cast SimpleApplication to get rootNode.</p></li><li><p>You no longer call super during cleanup, its done for you now.</p></li><li><p>It is now safe to do all initialization and cleanup in the onEnable()/onDisable() methods. Choosing to use initialize() and cleanup() for this is a matter of performance specifics for the implementor.</p></li><li><p>Cleanup and setEnabled now have logging built in.</p></li></ul></div>
|
|
|
-<div class="paragraph"><p>You use BaseAppState no differently than AbstractAppState, other than mentioned above, and which one you use is entirely up to you. However, BaseAppState makes your life easier and is the recommended one to use now.</p></div>
|
|
|
+<div class="ulist"><ul><li><p>You no longer need to call super.initialize(stateManager, app) because it is now called by BaseAppState upon initialization for you.</p></li><li><p>You no longer have to cast SimpleApplication to have access to AssetManager, AppStateManager, and you can even get a State directly. The getters getApplication(), getAssetManager(), getState(type) and their methods are available to you immediately. However, you still have to cast SimpleApplication to get rootNode.</p></li><li><p>You no longer call super during cleanup, its done for you now.</p></li><li><p>It is now safe to do all initialization and cleanup in the onEnable()/onDisable() methods. Choosing to use initialize() and cleanup() for this is a matter of performance specifics for the implementor.</p></li><li><p>Cleanup and setEnabled now have logging built in.</p></li></ul></div>
|
|
|
+<div class="paragraph"><p>You use BaseAppState as you would AbstractAppState, other than mentioned above, and which one you use is entirely up to you. However, BaseAppState makes your life easier and is the recommended one to use now.</p></div>
|
|
|
<div class="paragraph"><p>If you use the jme SDK you can add the following template to make adding BaseAppState to your project easier.</p></div>
|
|
|
-<div class="ulist"><ul><li><p>From the SDK select <span class="menuseq"><span class="menu">Tools</span> ▸ <span class="submenu">Templates</span> ▸ <span class="submenu">JME Classes</span> ▸ <span class="menuitem">New AppState</span></span>.</p></li><li><p>Click the <b class="button">Duplicate</b> button.</p></li><li><p>Rename this newly created copy to “New BaseAppState”.</p></li><li><p>Select <b class="button">Open In Editor</b>.</p></li><li><p>Select all text in the open file and delete it.</p></li><li><p>Copy and paste the code below into the file.</p></li></ul></div>
|
|
|
-<div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java"><<span class="error">#</span>assign licenseFirst = <span class="string"><span class="delimiter">"</span><span class="content">/*</span><span class="delimiter">"</span></span>>
|
|
|
-<<span class="error">#</span>assign licensePrefix = <span class="string"><span class="delimiter">"</span><span class="content"> * </span><span class="delimiter">"</span></span>>
|
|
|
-<<span class="error">#</span>assign licenseLast = <span class="string"><span class="delimiter">"</span><span class="content"> */</span><span class="delimiter">"</span></span>>
|
|
|
-<<span class="error">#</span>include <span class="string"><span class="delimiter">"</span><span class="content">../Licenses/license-${project.license}.txt</span><span class="delimiter">"</span></span>>
|
|
|
+<div class="ulist"><ul><li><p>From the SDK select <span class="menuseq"><span class="menu">Tools</span> ▸ <span class="submenu">Templates</span> ▸ <span class="submenu">JME Classes</span> ▸ <span class="menuitem">New AppState</span></span>.</p></li><li><p>Click the <b class="button">Duplicate</b> button.</p></li><li><p>Rename this newly created copy to “New BaseAppState”.</p></li><li><p>Select <b class="button">Open in Editor</b>.</p></li><li><p>Select all text in the open file and delete it.</p></li><li><p>Copy and paste the code below into the file.</p></li></ul></div>
|
|
|
+<div class="listingblock"><div class="content"><pre><#assign licenseFirst = "/*">
|
|
|
+<#assign licensePrefix = " * ">
|
|
|
+<#assign licenseLast = " */">
|
|
|
+<#include "../Licenses/license-${project.license}.txt">
|
|
|
|
|
|
-<<span class="error">#</span><span class="keyword">if</span> <span class="keyword">package</span>?? && <span class="namespace">package</span> != <span class="string"><span class="delimiter">"</span><span class="delimiter">"</span></span>><span class="namespace">package</span> <span class="error">$</span>{<span class="namespace">package</span>};
|
|
|
-</<span class="error">#</span><span class="keyword">if</span>><span class="keyword">import</span> <span class="include">com.jme3.app.Application</span>;<span class="keyword">import</span> <span class="include">com.jme3.app.state.BaseAppState</span>;
|
|
|
+<#if package?? && package != "">package ${package};
|
|
|
+</#if>import com.jme3.app.Application;import com.jme3.app.state.BaseAppState;
|
|
|
|
|
|
-<span class="comment">/**
|
|
|
+/**
|
|
|
*
|
|
|
* @author ${user}
|
|
|
- */</span>
|
|
|
-<span class="directive">public</span> <span class="type">class</span> <span class="error">$</span>{name} <span class="directive">extends</span> BaseAppState {<span class="error"> </span><span class="error"> </span><span class="error"> </span> <span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
+ */
|
|
|
+public class ${name} extends BaseAppState {
|
|
|
|
|
|
- <span class="annotation">@Override</span><span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="directive">protected</span> <span class="type">void</span> initialize(Application app) {<span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="comment">//It is technically safe to do all initialization and cleanup in the </span>
|
|
|
- <span class="comment">//onEnable()/onDisable() methods. Choosing to use initialize() and </span>
|
|
|
- <span class="comment">//cleanup() for this is a matter of performance specifics for the </span>
|
|
|
- <span class="comment">//implementor. </span>
|
|
|
- <span class="comment">//TODO: initialize your AppState, e.g. attach spatials to rootNode </span>
|
|
|
+ @Override
|
|
|
+ protected void initialize(Application app) {
|
|
|
+ //It is technically safe to do all initialization and cleanup in the
|
|
|
+ //onEnable()/onDisable() methods. Choosing to use initialize() and
|
|
|
+ //cleanup() for this is a matter of performance specifics for the
|
|
|
+ //implementor.
|
|
|
+ //TODO: initialize your AppState, e.g. attach spatials to rootNode
|
|
|
}
|
|
|
-<span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="annotation">@Override</span><span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="directive">protected</span> <span class="type">void</span> cleanup(Application app) {<span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="comment">//TODO: clean up what you initialized in the initialize method, </span>
|
|
|
- <span class="comment">//e.g. remove all spatials from rootNode </span>
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void cleanup(Application app) {
|
|
|
+ //TODO: clean up what you initialized in the initialize method,
|
|
|
+ //e.g. remove all spatials from rootNode
|
|
|
}
|
|
|
-<span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="comment">//onEnable()/onDisable() can be used for managing things that should </span>
|
|
|
- <span class="comment">//only exist while the state is enabled. Prime examples would be scene </span>
|
|
|
- <span class="comment">//graph attachment or input listener attachment. </span>
|
|
|
- <span class="annotation">@Override</span><span class="error"> </span><span class="error"> </span><span class="error"> </span> <span class="directive">protected</span> <span class="type">void</span> onEnable() {<span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="comment">//Called when the state is fully enabled, ie: is attached and </span>
|
|
|
- <span class="comment">//isEnabled() is true or when the setEnabled() status changes after the </span>
|
|
|
- <span class="comment">//state is attached. </span>
|
|
|
+
|
|
|
+ //onEnable()/onDisable() can be used for managing things that should
|
|
|
+ //only exist while the state is enabled. Prime examples would be scene
|
|
|
+ //graph attachment or input listener attachment.
|
|
|
+ @Override protected void onEnable() {
|
|
|
+ //Called when the state is fully enabled, ie: is attached and
|
|
|
+ //isEnabled() is true or when the setEnabled() status changes after the
|
|
|
+ //state is attached.
|
|
|
}
|
|
|
-<span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="annotation">@Override</span><span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="directive">protected</span> <span class="type">void</span> onDisable() {<span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="comment">//Called when the state was previously enabled but is now disabled </span>
|
|
|
- <span class="comment">//either because setEnabled(false) was called or the state is being </span>
|
|
|
- <span class="comment">//cleaned up. </span>
|
|
|
- }<span class="error"> </span><span class="error"> </span><span class="error"> </span> <span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDisable() {
|
|
|
+ //Called when the state was previously enabled but is now disabled
|
|
|
+ //either because setEnabled(false) was called or the state is being
|
|
|
+ //cleaned up.
|
|
|
+ }
|
|
|
|
|
|
- <span class="annotation">@Override</span><span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="directive">public</span> <span class="type">void</span> update(<span class="type">float</span> tpf) {<span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
- <span class="comment">//TODO: implement behavior during runtime </span>
|
|
|
- }<span class="error"> </span><span class="error"> </span><span class="error"> </span>
|
|
|
-}</code></pre></div></div>
|
|
|
-<div class="paragraph"><p>See link:http://javadoc.jmonkeyengine.org/com/jme3/app/state/BaseAppState.htmlBaseAppState for more information.</p></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2017-08-13 19:56:24 UTC</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
|
|
|
+ @Override
|
|
|
+ public void update(float tpf) {
|
|
|
+ //TODO: implement behavior during runtime
|
|
|
+ }
|
|
|
+}</pre></div></div>
|
|
|
+<div class="paragraph"><p>See <a href="http://javadoc.jmonkeyengine.org/com/jme3/app/state/BaseAppState.html">BaseAppState</a> for more information.</p></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2017-08-13 20:06:43 UTC</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
|
|
|
apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
|
|
|
indexName: 'jmonkeyengine',
|
|
|
inputSelector: '#doc-search',
|