joshcamas Posted October 4, 2016 Share Posted October 4, 2016 Hey guys! Right now I have a topdown game where you select a tile and the player will find a path and walk to it, using tween chains. I have a spritesheet with frames of a character walking up, down, left, right. I come from a Flixel background, so I figured I'd be able to check velocity and use that to see which direction I'm going... problem is that looks like a physics thing not a tween thing. I'll probably just compare last frame's X to the current frame's X... but is there a better way built in? EDIT: I've tried to check the comparison of the last frame's x and the current frame, but it looks like it stutters to thinking the values are equal when a tween in a chain completes for a frame, and then starts the other tween. (Which is unnoticeable ingame) Thanks! Link to comment Share on other sites More sharing options...
tips4design Posted October 4, 2016 Share Posted October 4, 2016 Are you using frameBased tweens? Link to comment Share on other sites More sharing options...
joshcamas Posted October 4, 2016 Author Share Posted October 4, 2016 I'm not sure, am I? var tween = game.add.tween(this).to({x:X,y:Y}, time); Link to comment Share on other sites More sharing options...
tips4design Posted October 4, 2016 Share Posted October 4, 2016 No, the default is not to use frameBased tweens, see this: http://phaser.io/docs/2.6.2/Phaser.TweenManager.html#frameBased So, tweens velocities might vary if your game doesn't run at 60FPS. Now, considering your game runs at 60FPS, what's the problem if you compute this position minus the position last frame? Link to comment Share on other sites More sharing options...
samme Posted October 5, 2016 Share Posted October 5, 2016 3 hours ago, joshcamas said: I'll probably just compare last frame's X to the current frame's X... but is there a better way built in? You can use `sprite.deltaX()`, `sprite.deltaY()`. Link to comment Share on other sites More sharing options...
Recommended Posts