Hello, I am currently in the process of learning how to use states so I can implement them in my game(not going to actually be released, just a game i’m making to help get familiar with jmonkey). I understand the basics of states, but I feel like seeing where and how people implemented them would help me understand optimal usage.
I’m new to this website, so i’m not sure where to post this sort of question, so sorry if it was not in the correct location.
March 13, 2019, 11:49pm
By “state” you mean
March 14, 2019, 1:26am
Tons of examples around…
Some more complicated ones here:
Some non-game ones but still illustrative here:
A complete single-player game example:
This is a relatively straight-forward example that replaces JME’s (ill-conceived) FlyByCamera with a Lemur InputMapper based AppState:
So, as some of you may know, Lemur is a light-weight GUI library that lets you make labels, buttons, and other twiddly bits in either 2D or 3D user interfaces.
The core design of Lemur was to build several modular toolkits that together form a full-up GUI library. Consequently, some of these toolkits have great utility even if you choose not to use the GUI elements themselves. This Gem covers one of these: InputMapper
The whole project can be found here:
March 14, 2019, 11:26pm
In case staring at other people’s code isn’t your thing, here’s an app-state dump of my current (closed-source) WIP.
The game currently uses 16 app states.
The 1st four seem to be built into
SimpleApplication: I don’t use them much.
Then come 3 input modes: no more than one input mode can be enabled at any given time.
MainHud each control one screen in the GUI: again, only one can be enabled at a time.
MapTool control non-modal subwindows in the GUI. They depend on
MainHud, so they can be enabled only if
MainHud is enabled.
BulletAppState: manages the game’s physics simulation.
View: manages the scene graph.
DynamicCamera: controls the rendering Camera.
PerformanceAppState: is my custom performance monitor.
AppStateManager with 16 states: 16 active
active: ResetStatsState enabled
active: StatsAppState enabled
active: AudioListenerState enabled
active: DebugKeysAppState enabled
active: DefaultInputMode enabled
active: DialogInputMode disabled
active: MenuInputMode disabled
active: BindScreen disabled
active: BulletAppState enabled NOdebug speed=1 bphase=DBVT
PhysicsSpace #59ccdd30 contains 0 characters, 0 ghosts, 4 joints, 171 rigid bodies, and 0 vehicles
accu=0.016667, bphase=DBVT, grav=[x=0 y=-9.81 z=0], maxStep=4
iters=15, rayTest=(SubSimplexConvexCast), wMin=[xyz=-10000], wMax=[xyz=10000]
active: DsScreen disabled
active: DynamicCamera enabled
active: MainHud enabled
active: PerformanceAppState disabled
active: View enabled
active: DumpTool disabled
active: MapTool disabled