Jump to content

State changing animation


MichaelD
 Share

Recommended Posts

Hello,

 

I wanted to ask if there is a way to tween a state when we enter it or when we leave it. Basically if some animation like "fade-in/out" can be applied to states.

 

After some search I found this: https://github.com/cristianbote/phaser-state-transition, but I'm not sure if it is compatible with the latest Phaser version. If anyone has used this let me know if it is worth it.

 

 

Thanks.

Link to comment
Share on other sites

You have to manually start tweens. You can start a tween at the end of your `create` method, or somewhere that your state ends. You might want to keep the tweens in sync. 

 

For example i have two states `state1` and `state2` At the end of `state1` I start a tween, from `alpha:0` to `alpha:1` for a white rectangle. That fades the screen to white. And then switch to `state2` and at the end of `create` method, I start a tween from `alpha:1` to `alpha:0` for a white rectangle. That fades the screen from white to `state2`. That's a manual transition.

Link to comment
Share on other sites

I did try it, it doesn't seem to work after 2.0.6

 

I will probably try the given code but it seems like a big feature that is missing from Phaser, I mean transitions between states seem like a big-deal... or is everyone doing something else I am missing?

Link to comment
Share on other sites

Sure.

var transitionPlugin = game.plugins.add(Phaser.Plugin.StateTransition);transitionPlugin.settings({  // how long the animation should take  duration: 750,  // ease property  ease: Phaser.Easing.Quadratic.Out, /* default ease */  // what property should be tweened  properties: {    alpha: 0  }});

Then to move to a new state:

transitionPlugin.to('StateName');
Link to comment
Share on other sites

  • 6 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...