Jump to content

Scale Tweening causing unwanted movement


zencha
 Share

Recommended Posts

Hey guys,

 

I'm currently working through Discover Phaser making Thomas's Super Coin Box tutorial.

 

I just created some tweens for when a player grabs a coin. The tweens play correctly, but afterwards the player begins slowly moving right without input and the coins begin moving up-left at a particular angle.

 

Here's the relevant code:

takeCoin: function(player, coin){            game.global.score += 5;            this.scoreLabel.text = 'score: ' + game.global.score;            this.coinSound.play();            this.updateCoinPosition();      },      updateCoinPosition: function(){            var coinPosition = [                  {x: 140, y: 60}, {x: 360, y: 60},                  {x: 60, y: 140}, {x: 440, y: 140},                  {x: 130, y: 300},{x: 370, y: 300}            ];            for (var i = 0; i < coinPosition.length; i++){                  if (coinPosition[i].x === this.coin.x){                        coinPosition.splice(i, 1);                  }            }            var newPosition = coinPosition[                game.rnd.integerInRange(0, coinPosition.length-1)];            this.coin.reset(newPosition.x, newPosition.y);            this.coin.scale.setTo(0,0);            game.add.tween(this.coin.scale).to({x: 1, y: 1}, 300).start();            game.add.tween(this.player.scale).to({x: 1.5, y: 1.5}, 50).to({x: 1, y: 1}, 150).start();
Link to comment
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...
 Share

  • Recently Browsing   0 members

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