Jump to content

animation onComplete callback


metalslug87
 Share

Recommended Posts

Hello,

I've problem with animation complete callback, when fired first time it's ok. On next function executions it's adding additional console.log value "nut fired".

So the JS console output looks like that (it's adding additional execution of animation callback):

nut fired! -> nut fired! (3) -> nut fired! (6) -> nut fired! (10) ...

 

function squirellThrowNut () {
    for (var i = 0; i < squirells.length; i++) {
        squirells.children[i].animations.play('throw');
        
        squirells.children[i].animations.currentAnim.onComplete.add(function () {           
            for (var i = 0; i < squirells.length; i++) {
                console.log('nut fired!');
            }
        }, this);  
    };
}

 

Please help me, I can't figure it out.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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