AppState: best practises?

Some of the old JME app states are pretty bad examples to follow. If they aren’t extending BaseAppState then they are probably half-broken. BaseAppState should be the base class you use as there are nicer life cycle methods to override. (As to why app state manager is passed in the AppState interface it’s because many many many app states will want to lookup sibling app states and it saves them a call… BaseAppState’s initialize only passes Application because it’s already grabbed the state manager and provides convenient getState() methods already locally.)

If you want to see good examples of app state use then you can look at any of the many examples I have out there… whether the half-dozen AppStates in Lemur or in any of my sample apps.

For example, some recent sample apps:

Some older more complicated apps:

All of which heavily use app states.

1 Like