Search code examples
libgdxrotationmoveforward

Libgdx - How to move object forward by direction?


Example: I have 3 object with 3 rotation so how can i move object forward by object's direction like that.

https://i.sstatic.net/pTWDf.png


Solution

  • If you are using sprites to hold to values of each object, set the x/y += direction you want the objects to travel. Otherwise, if you are drawing the image through a spritebatch you can use batch.draw(texture, x, y) and set the x and y coordinates that way.