Sign in to follow this  
Biggerplay

Remove tween when it's complete?

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);        });    },

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

Oh, sorry, I misread your post.  If you want to remove the text when the tween is complete, I would call the destroy function on the scoreText object.

 

So replace line 12 with: 

scoreText.destroy();

Let me know if that does what you need.  

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.