Don’t know if I’m over-thinking this or not.. but I’m trying to be able to adjust the sprites showing when my character is moving in different directions.
For example, if the players finger is above the character I want it to go to the ‘moveUp’ frame. If the players’ finger is below the character I want to go to the ‘moveDown’ frame, otherwise stay at the ‘normalState’ frame.
Can someone show me an example of this? Or direct me to a good general tutorial about implementing Sprite sheets/Sprites in this sort of way.
I have gone through and used sprite sheets in demo projects but am looking to release this and want to approach it the proper and most successful way.
Thanks!!
I assume you have already made your sprite sheet and/or packed it (I like TexturePacker). The code would be something like:
If you want other directions (W, E, NW, etc..) I would suggest you convert the
touchPositionRelativeToPlayerto an angle usingatan2and determine the frame from that.