Jump to content

Restarting tween when isRunning


3ddy
 Share

Recommended Posts

Hey, 
I have a tween that should start everytime user clicks on object. When tween didn't finish (it has yoyo=true) yet, I want to set its properties to initial ones and start the tween again. I've tried approach from this topic but it's not working : 

Take a look at my code:
 

in create:

this.obj.tween = game.add.tween(this.obj.scale).to({x: 0.5, y: 0.5}, 200, Phaser.Easing.Quadratic.Out, false, 0, 0, true);
		this.obj.tween.pendingDelete = false;

in onClick event:

if(this.obj.tween.isRunning) {
			this.obj.tween.stop();
			this.obj.tween.pendingDelete = false;
			this.obj.scale.setTo(1);
			this.obj.tween.start();
		} else {
			this.obj.scale.setTo(1);
			this.obj.tween.start();
		}

If I click when isRunning == true, then the scale resets to 1 but tween is not starting again - what am I doing wrong? When I set yoyo to false, then my solution is working. Probably some error occurs when the tween is yoyo'ing and I start to stop it.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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