WayardEmcee Posted August 2, 2014 Share Posted August 2, 2014 So basically I have an object called MoveManager. It gets instantiated and assigned a sprite and it moves that sprite based on blah blah blah parameters independently of all other MoveManagers. Now, I want to sprite to move at a certain rate say +32 x every 500ms. What would be the optimal solution (I presume using timer for shooting out events) to move the sprite in the aforementioned way. I'm still kind of struggling to comprehend javascript's ambiguity since I'm used to more strict languages. Link to comment Share on other sites More sharing options...
eguneys Posted August 4, 2014 Share Posted August 4, 2014 Use a tween.this.game.add.tween(sprite).to({ x: destination }, Phaser.Easing.Linear.None, 1000, true);This will only run for 1 second and move property x to destination. Also increase the x property every frame linearly. So if you want fine grained control, use timer.this.game.time.events.loop(500, moveSpriteBy32, this);// this.game.time.events.add will trigger once// this.game.time.events.loop will trigger forever// this.game.time.events.repeat will trigger any number of times clark 1 Link to comment Share on other sites More sharing options...
Recommended Posts