Jump to content

Identify current animation - suggestion


InsaneHero
 Share

Recommended Posts

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

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

}

Link to comment
Share on other sites

  • 3 years later...
 Share

  • Recently Browsing   0 members

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