Jump to content

Remove tween when it's complete?


Biggerplay
 Share

Recommended Posts

@programlocura

 

I'm using 1.1.3

 

I tried that but it's giving me the error "Uncaught TypeError: Object #<Object> has no method 'removeTween'"

 

I'm fairly certain there's something wrong in this function as I'm new to JS so here's the complete function..

 risingText:function(text, xx, yy)    {        var scoreText = this.game.add.bitmapText(xx, yy, text, { font: '48px Allgemeine', align: 'left' });        var bounce= this.game.add.tween(scoreText);        bounce.to({ x: xx, y: yy-60 }, 1000 + Math.random() * 3000, Phaser.Easing.Linear.In);        bounce.start();        bounce.onCompleteCallback( function() {            this.game.removeTween(scoreText);        });    },
Link to comment
Share on other sites

You are trying to call the function removeTween on your game object. (line 12) The game object doesn't have such a function, which is why you are getting your error.

 

What you want to do is remove the tween from the game's tween manager.

 

Replace line 12 with: 

this.game.tweens.remove(bounce); //tweens is a reference to the tween manager

This line works on Phaser 1.1.3 and 1.1.4

Link to comment
Share on other sites

You are trying to call the function removeTween on your game object. (line 12) The game object doesn't have such a function, which is why you are getting your error.

 

What you want to do is remove the tween from the game's tween manager.

 

Replace line 12 with: 

this.game.tweens.remove(bounce); //tweens is a reference to the tween manager

This line works on Phaser 1.1.3 and 1.1.4

Does that remove the scoreText when the tween is complete?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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