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

 Share

  • Recently Browsing   0 members

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