Hi Cristian,

You are correct, that it is not called within the plugin, but from outside
it. (in the create of the target state.)

The problem was, that the transition-sprite was behind sprites that were
created in the create() functions of the state that I transition to (target
state).

My fix was to create this "bringToTop" function, and then call it as a last
statement in the create function of the target state.

My first solution was:
myTransitionPluginInstance._cover.bringToTop();

Since I did not want to access the "private" _cover variable, I wrote the
bringToTop Function for the plguin.

I admit, that this is not really a good solution, because it has to be
manually put into every target state. Maybe you find a better way.

A better real solution would be to somehow make phaser call this function,
after the new state has been created. (I am not sure if there are events
available for such a callback, or if a plugin could insert them).

I hope this clarifies the function.
You can of course omit it for now.


On Tue, Feb 4, 2014 at 8:59 AM, cristianbote <notifications@github.com>wrote:

> In src/phaser-state-transition.js:
>
> > @@ -48,6 +48,13 @@
> >  		_draw.call(this, state);
> >  	};
> >
> > +	/** Can be called in the create function of states that you transition to, to ensure
> > +	  * that the transition-sprite is on top of everything
> > +	  */
> > +	Phaser.Plugin.StateTransition.prototype.bringToTop = function () {
>
> Is this being called somewhere?
> I can't seem to locate where you're gonna call it. I assume inside the
> _draw method, but it's not there
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/cristianbote/phaser-state-transition/pull/1/files#r9413067>
> .
>