Jump to content

Group for animations


Meowts
 Share

Recommended Posts

I noticed that groups do not accept animation objects as children, so I'm wondering what would work better. Here's the gist:

//The sprite group "path" already exists with a variable amount of sprites.//All the sprites except the first in the group needs an animation, that play one after the other,//so I thought I'd create a new group and take advantage of the next() method.this.animGroup = this.game.add.group();path.forEach(function(pathItem){    //When it isn't the start button, add the animation to the path sprite    if(path.getBottom() != pathItem){        var pathAnim = pathItem.animations.add('select');        pathAnim.enableUpdate = true;        pathAnim.onUpdate.add(function(){this.sfx.play()}, this);        this.animGroup.add(pathAnim); //no go    }}, this);//and then for the animation group, have each of the onComplete call the next child.//animatePath() just calls the play() method, and on the last one something else happensthis.animGroup.forEach(function(animItem){    if(this.animGroup.getTop() != animItem){        animItem.onComplete.add(function(){this.animatePath(animItem.next())}, this);    }    else{        animItem.onComplete.add(function(){this.fadePaths(path)}, this);    }}, this);

See what I'm getting at? It just breaks when trying to add the animation to the new animGroup.

Link to comment
Share on other sites

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