cristianbote/phaser-state-transition — pull request #4 by jpcloud (2014-02-04 19:25:30+00:00)
Title: Optional fillColor for transition

Hi Cristian,

I have again made changes to your plugin.

One is kind of a bugfix, it's line 62:
you checked settings[p] for true/false, this did not allow to have boolean properties in settings that were default false. (because then, they would never be set, because settings['useFillColor'] for example would evaluate to false.) - I changed it to hasOwnProperty (it's what stack overflow suggested, it checks if the object settings has the property p).

The other change is a feature - it is an option to color the transition texture before the world is drawn to it.

Reason behind the feature:
If the game always paints the complete screen without leaving any holes, then this option is of course not needed. My game (and I guess some other games) just sets a background color and draws only the needed sprites, the background color acts as a sky/background. Now, if this world is drawn into the transition texture, it has "holes" where the texture is still clear, so you see the new state through these "holes" during the transition. (because the worlds background color is not drawn to the texture, only the sprites.)
Using the fillColor option (by setting useFillColor to true, and fillColor to the desired color) there are no longer "holes" in the transition texture and the transition looks better.
(The only way I knew how to do this was to paint a graphics object and render it to the texture, if you know a better way to draw to a texture, please let me know!)

I tested it in canvas and webGL mode. (But still using my phaser 1.1.4 build from 2 weeks ago, so you might want to double check if you want to merge it.)

Also: This time I made a feature branch in my fork of the phaser-state-transition repo. (Still learning git.. after you accepted my first pull request, I did not manage to get my fork to the same code as your original.. (I had to delete my fork and refork) maybe with this feature branch, i can then update my master correctly.. that's my hope at least.)

Greetings,
JP