You need to use a little algebra to determine the actual amount of pixels the player should traverse when moving diagonally. As you've described, your player is actually moving FOUR pixels worth of distance when moving diagonally as opposed to just two when moving up down left or right.
There should be built-in method for handling this, I can't remember of the top of my head. I think somebody mentioned the tutorial, which is a great place to start and definitely the way to go. However if you want to understand the actual solution, read on.
What you want to use for calculating diagonal movement is the Pythagoras theorem. In your case, you know you want to move 2px in a diagonal direction. What you need to figure out is how many pixels left/right and up/down that equates to. So 2px is your hypotenuse and the other sides are equal.
Let's call the unknown sides "a" since we know they're equal.
a^2 + a^2 = 2^2
2a^2 = 4
a^2 = 2
a = √2
a = 1.4142...
So you can round that to whatever precision you want, but essentially when you move diagonally that's how many pixels your player should go. Hope that explains things for you! Feel free to ask questions :-)
The problem is simple, if I press UP the char moves 2 pixels up, while LEFT will make it movev 2 pixels left. However when I press both UP and LEFT (or any diagonal movement), the char seems to move faster in the diagonal direction. Any practical way to fix it so that it seems that the char moves at the same speed in any direction?
--
HaxeFlixel Development Community
See our github https://github.com/haxeflixel/ and our documentation http://haxeflixel.com/documentation/
---
You received this message because you are subscribed to the Google Groups "HaxeFlixel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haxeflixel+...@googlegroups.com.
Visit this group at http://groups.google.com/group/haxeflixel.
To view this discussion on the web visit https://groups.google.com/d/msgid/haxeflixel/609102d8-7b32-4951-bfa9-425312087ae1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.