How to rotate a player to face left and right

rab127rab127 Member, PRO Posts: 47
edited November -1 in Working with GS (Mac)
Hi

Noob question

I am building a game based on the basic shooter. I would like the ship, actor, to face the direction it is going. How is the done? I've been searching the forum tried some ANgletoVector but this didn't work

Comments

  • xarmianxarmian Member Posts: 124
    you were on the right track.. you should either have an x/y coordinate the ship is traveling to, or have a rotation value. If you have a rotation value then you just set self.rotation equal to that value. If you're traveling to an x,y coordinate then:

    change attribute self.rotation to:
    vectorToAngle(moveToX - self.position.X, moveToY - self.position.Y)

    Where moveToX and moveToY are the X and Y coordinates you are moving toward. This will rotate your actor to face those x/y coordinates. This calculation assumes the image on your actor faces right (angle 0).
  • rab127rab127 Member, PRO Posts: 47
    Thanks that did rotate it but now I see I need to invert the image not rotate it.

    the control is fine I need the image to change when "left" or "Right" are pressed
  • xarmianxarmian Member Posts: 124
    Ah. In that case you just need to change self.Graphics.FlipHorizontally or FlipVertically (whichever you need) to TRUE to flip the image when you want it flipped. Change it back to 0 to make the image go back to its original orientation.
Sign In or Register to comment.