Meowts Posted February 18, 2014 Share Posted February 18, 2014 Hey! I'm a newbie game developer, and for start I just want to say that Phaser is providing me an excellent way to get into game development!! So, I have a spritesheet with images that I'd like to have showing under certain conditions. I'm achieving that by defining a bunch of single frame 'animations' that are being called to play when the conditions are met. I'm alright with this, but I'm wondering for efficiency sake if there's a way to just define a single animation, and then say something like:if(condition1){animation.play('anim', [1], 10);animation.stop();}if(condition2){animation.play('anim', [2], 10);animation.stop();}I realize the play function doesn't take in the frame index value, but is there another approach I could take here? Am I over-thinking it? Thanks for any tips! Link to comment Share on other sites More sharing options...
rich Posted February 18, 2014 Share Posted February 18, 2014 Sure, just do:Sprite.frame = 2;Where 2 is whatever frame you want to show. This works for sprite sheets. If you're using a Texture Atlas and the frames have names, you'd use Sprite.frameName instead. binarez 1 Link to comment Share on other sites More sharing options...
Meowts Posted February 18, 2014 Author Share Posted February 18, 2014 Aha! Awesome, thanks a lot!! Link to comment Share on other sites More sharing options...
Recommended Posts