Jump to content

animation onComplete trouble


osinski
 Share

Recommended Posts

Hey!

I'm trying to use listener onComplete for animation:

var boom_tile = game.add.sprite(checked_tile_x, checked_tile_y, "boom");boom_tile.anchor.setTo(0.5, 0.5);boom_tile.animations.add("boom").onComplete.add(function(){console.log("ON COMPLETE!")});

But got error: TypeError: boom_tile.animations.add(...).onComplete.add is not a function

 

Could you help me?

Link to comment
Share on other sites

Hmm, it seems like it should work, though I've not chained it like that before - does this work?

var anim = boom_tile.animations.add("boom");anim.onComplete.add(function() {  console.log("ON COMPLETE!");});anim.play();

If not, it may give you a better indication of where the error lies at least...

Link to comment
Share on other sites

Its my function, I changed it like your example:

function removeTiles (i, j){    var checked_tile = tilesList[i][j];    var checked_tile_x = checked_tile.x;    var checked_tile_y = checked_tile.y;    var boom_tile = game.add.sprite(checked_tile_x, checked_tile_y, "boom");    boom_tile.anchor.setTo(0.5, 0.5);    //add animation    var anim = boom_tile.animations.add("boom");    anim.onComplete.add(function() {        console.log("ON COMPLETE!");    });    anim.play();}

And got same error: TypeError: anim.onComplete.add is not a function

Link to comment
Share on other sites

It's no difference:

function removeTiles (i, j){    var checked_tile = tilesList[i][j];    var checked_tile_x = checked_tile.x;    var checked_tile_y = checked_tile.y;    var boom_tile = game.add.sprite(checked_tile_x, checked_tile_y, "boom");    boom_tile.anchor.setTo(0.5, 0.5);    //add animation    var anim = boom_tile.animations.add("boom", [1, 2], 2);    anim.onComplete.add(function() {        console.log("ON COMPLETE!");    });    anim.play();}

Again TypeError: anim.onComplete.add is not a function. Without onComplete all works nice.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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