mcuz Posted April 26, 2014 Share Posted April 26, 2014 I have been looking at using tweens for having a sprite move in a circle. I have been successful by using easing.circular on y axis while using easing.linear on x axis but since it is easingthe sprite speeds up on parts of the path and then slows down on others. Is their anyway to use easing such that i canhave a sprite follow a circular path at a constant speed. I can do this using physics and writing my own trig code, just wondering if tweening offers another way (or is there anothermethod in phaser that I just don't know about???) any replies much obliged mcuz Link to comment Share on other sites More sharing options...
Jorasso Posted April 26, 2014 Share Posted April 26, 2014 You should use sineIn and sineOut. Here is how I make sprite following the circle with createjs in my own code (not Phaser), but should give you the idea how to achieve it in Phaser too:var centerX = 300;var centerY = 300;var r = 200;this.block.x = centerX + r;this.block.y = centerY;createjs.Tween.get (this.block, {loop: true }) .to ({x: centerX}, 500, createjs.Ease.sineIn) .to ({x: centerX - r}, 500, createjs.Ease.sineOut) .to ({x: centerX}, 500, createjs.Ease.sineIn) .to ({x: centerX + r}, 500, createjs.Ease.sineOut);createjs.Tween.get (this.block, {loop: true }) .to ({y: centerY - r}, 500, createjs.Ease.sineOut) .to ({y: centerY}, 500, createjs.Ease.sineIn) .to ({y: centerY + r}, 500, createjs.Ease.sineOut) .to ({y: centerY}, 500, createjs.Ease.sineIn); andrii.barvynko and plicatibu 2 Link to comment Share on other sites More sharing options...
Recommended Posts