InsaneHero Posted October 1, 2014 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'. Link to comment Share on other sites More sharing options...
JUL Posted October 2, 2014 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 Link to comment Share on other sites More sharing options...
rich Posted October 9, 2014 Share Posted October 9, 2014 https://github.com/photonstorm/phaser/commit/b00866cee9a33fd4e30f3a7f799eda1139a86ad4 InsaneHero 1 Link to comment Share on other sites More sharing options...
InsaneHero Posted October 11, 2014 Author Share Posted October 11, 2014 Thanks JUL and Rich. Link to comment Share on other sites More sharing options...
trinity420 Posted June 15, 2018 Share Posted June 15, 2018 You can use sprite.animations.currentAnim.name. Worked for me! Link to comment Share on other sites More sharing options...
Recommended Posts