johnmccutchan/game_loop — pull request #57 by MarkBennett (2013-12-15 22:59:02+00:00)
Title: Add GameLoop#setState()

I added the simplest implementation of a `GameLoopState` I could possibly come up with. The purpose of this PR is to enable you to collect GameLoop handlers into a state object you can use to represent different parts of your game (cinematic, menu, gameplay, etc.)

This is inspired by the state code in jaws.js.

If you are interested in this and merge this PR, then future possible expansions include:

1. Introduce a stack of states and allow navigation backward / forward in the stack (like in a browser)
2. Events which are triggered on the state when it is entered or existed (onStateEnter, onStateExit)

Things I am looking for feedback on include:

* Handling the case where a user mixes directly setting handlers with setting the state
* The syntax for creating states, especially custom subclasses

Feedback and requests for changes are welcome. Thanks!