I am playing around with the Asteroid example by implementing a UI to show lives and points, and I have a question on best practices for implementing this feature. I have looked at the other topics and created my HUD outside of the game and implemented an Event Bus that I pass into the game. For lives, the game manager dispatches an event and the HUD picks it up and that seems like the best for that.
if (clearToAddSpaceship)
{
eventBus.dispatch( EventBus.LIVES_EVENT, new LifeEvent(node.state.lives) );
creator.createSpaceship();
node.state.lives--;
}
For the points, however, I am not sure I am doing it the best way. I modified the collision system to be aware of GameNodes. When ever an asteroid is destroyed I update the GameNode. Then the GameManager dispatches an event for the HUD to pick up.
Is there a better way of doing this?