Simple Question - AbstractAppState or not?

Hi,

Should I make each player and npc extend AbstractAppState or should I make on object that extends AbstractAppState
that then updates all the npcs and players?

Its up to you really, but for #1 I wouldn’t make player/npc extend AbstractAppState, it would be better to give them Controls (composition). AppStates were originally setup for controlling “global” game state (#2) and stuff which could be turned off and on very easily (transitioning between GUI screens, changing inputMappings etc). Controls were more designed for individual entities (characters etc).

3 Likes

Yeah, attach controls to the player/npc to handle the stuff specific to that npc and then use app states for global stuff.

i.e. An app state might load the map, populate it with models and attach the correct controls to those models.

The models and controls will then run from there.

1 Like

Good point guys.
I will have to do some major changes to implement controls instead of appstates but it’s probebly worth it :slight_smile:

@Addez said: Good point guys. I will have to do some major changes to implement controls instead of appstates but it's probebly worth it :)

Considering that appstates and controls have the same general interface, this should end up being a very simple switch.

1 Like
@t0neg0d said: Considering that appstates and controls have the same general interface, this should end up being a very simple switch.

…except AppStates have a lifecycle and controls don’t. AppStates have access to the Application through the lifecycle calls and controls don’t, etc…

If he was using AppStates properly then there could be some work to do. Going from control to app state is easy but I could see how he has some work ahead of him in this direction.

1 Like