Jump to content

Group for animations


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


  • Recently Browsing   0 members

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