InsaneHero Posted October 1, 2014 Report Share Posted October 1, 2014 Could the Animation class gain a member which stores the current animation name?I'm finding that when I want to do anything above very basic animation I have to keep a local variable to remember which animation is being used, and if Animation had a 'name' member then it would simplify my code: if (chopper.animations.currentAnim.name == 'hover') chopper.animations.play('turnLeft'); Instead of needing a chopper.lastAnim variable which has to be constantly adjusted for every 'play'. Quote Link to comment Share on other sites More sharing options...
JUL Posted October 2, 2014 Report Share Posted October 2, 2014 if (animName(chopper)=='hover') chopper.play('turnLeft'); function animName(obj){ return obj.animations.currentAnim.name;} or if chopper is prototyped Chopper.prototype.update=function(){this[this.animations.currentAnim.name]();} Chopper.prototype.hover=function(){//do things on hover} InsaneHero 1 Quote Link to comment Share on other sites More sharing options...
rich Posted October 9, 2014 Report Share Posted October 9, 2014 https://github.com/photonstorm/phaser/commit/b00866cee9a33fd4e30f3a7f799eda1139a86ad4 InsaneHero 1 Quote Link to comment Share on other sites More sharing options...
InsaneHero Posted October 11, 2014 Author Report Share Posted October 11, 2014 Thanks JUL and Rich. Quote Link to comment Share on other sites More sharing options...
trinity420 Posted June 15, 2018 Report Share Posted June 15, 2018 You can use sprite.animations.currentAnim.name. Worked for me! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.