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...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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