Tween on Click stops after rapid clicks

Recommended Posts

Hey there! I'm pretty new to Phaser, but I've been making an idle clicker in it to learn the ropes.

I've run into some issues with tweens that I'm not to sure how to fix. I have a sprite, and when you click it, it increments a counter and plays a 'bouncy' tween, to display you clicked on it.

This is cookie clicker style, so the user will inevitably rapid fire click it at some point. The issue seems to be that after several rapid fire clicks, the tween just sort of gives up and stops working.

My first assumption is that because we're creating a tween each time we get some kind of overload of them because we're not properly destroying them? I'm unsure how to effectively do this in this situation.

The ways I attempted to fix it:

  • use game.tween.remove(tweenName) at the end of the function (expecting the next click to create a new one)
  • store tween in variable and if variable != null, clear variable before creating new tween in it.

Neither of these had results which makes me think I'm not understanding this correctly.


crystal = game.add.sprite(, - 5, 'crystal');
	crystal.inputEnabled = true;
	crystal.input.pixelPerfectOver = true;
	crystal.input.useHandCursor = true;
//on click event firing, this);

//this tween is just it moving up and down to 'float'
	game.add.tween(crystal.position).to( {y: + 5}, 2200, Phaser.Easing.Linear.InOut, true, 500, 20, true).loop(true);

//on click event function
function actionOnclick(){
	game.add.tween(crystal.scale).to({x: 0.95, y: 0.95}, 300, Phaser.Easing.Bounce.None, true, 300, 0, true);
	text.setText('Glamour: ' + counter);

Note: the tween doesn't need to complete if the user clicks again, just start over. It does this, but after so many rapid clicks it stops doing anything.

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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.