pwr Posted October 13, 2016 Share Posted October 13, 2016 Hi, I'm trying to use sinCosGenerator together with a tween to move the player only along the X axis of a sine wave. The 'player' is moving like I want, but I've set it to start at the middle of the game width, however on start it gets moved instantly to the left and it stars drawing the sine wave from there. I can't figure out why it's moving immediately to the left and not starting the wave in the middle as set. // generate sine waves var sin; var sinData = game.math.sinCosGenerator(game.height, game.width / 2, 1, 10); sin = sinData.sin; this.player = game.add.sprite(game.width / 2, 860, "player"); // move ship along sin horizontally this.sinTween = game.add.tween(this.player).to({ x: sin }, speed, Phaser.Easing.Linear.None, true, 0, -1); I'm new to Phaser so I'm probably missing something simple. What could be the issue? Thank you in advance for the help! Link to comment Share on other sites More sharing options...
samme Posted October 15, 2016 Share Posted October 15, 2016 Is it like this? http://codepen.io/anon/pen/amjbKB?editors=0010 Could you use Phaser.Easing.Sinusoidal instead? http://codepen.io/anon/pen/zKJxNk?editors=0010 Link to comment Share on other sites More sharing options...
Recommended Posts