MichaelD Posted July 29, 2014 Share Posted July 29, 2014 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 More sharing options...
Dumtard Posted July 29, 2014 Share Posted July 29, 2014 Why not give it a try, it seems quite easy to use and it says it is for v2.0.*. Link to comment Share on other sites More sharing options...
Heppell08 Posted July 29, 2014 Share Posted July 29, 2014 This may be of use to you then: http://www.html5gamedevs.com/topic/2016-rectangle-fade/ Link to comment Share on other sites More sharing options...
eguneys Posted July 29, 2014 Share Posted July 29, 2014 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 More sharing options...
MichaelD Posted July 29, 2014 Author Share Posted July 29, 2014 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 More sharing options...
Nick Posted July 30, 2014 Share Posted July 30, 2014 I'm running the State Transition plugin with 2.0.7 and it's working well for fading in/out of states. Link to comment Share on other sites More sharing options...
MichaelD Posted July 30, 2014 Author Share Posted July 30, 2014 Could you post your configuration options for me to see if I am missing something? Thanks! Link to comment Share on other sites More sharing options...
Nick Posted July 30, 2014 Share Posted July 30, 2014 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 More sharing options...
MichaelD Posted July 31, 2014 Author Share Posted July 31, 2014 Thanks it worked. Not sure why it wasn't before I had the exact same settings... Anyhow thanks again! Link to comment Share on other sites More sharing options...
beuleal Posted February 18, 2015 Share Posted February 18, 2015 Sorry to reopen this topic, but my transition isnt working how it should be, because my backgroud is colored... Im not using image, so the transitions is soo ugly What ive to do? Link to comment Share on other sites More sharing options...
Recommended Posts