Y touch position converted to angle?

jonnyDiamondjonnyDiamond Member Posts: 11
edited November -1 in Working with GS (Mac)
HI,

I want to be able to rotate an actor to an angle based on the Y position of a touch.

So, the higher the user touches on the Y axis, the closer to 359 degrees the actor rotates. The lower the touch, the closer to 0 degrees.

I have been trying to use - Rotate To Angle - but I don't know how to use vectorToAngle for just the Y.

Thanks a lot

Comments

  • msonesmsones Inactive, Chef Emeritus Posts: 75
    Game.touches.touch1.Y is (devices - touch - touch 1 - Y)

    I'm assuming your screen height is 320. If something else, change the 320 below to your screen height.

    Rotate to Angle, with angle as follows:

    =(game.touches.touch1.Y/320)*359

    This will make your actor rotate in a full circle depending on how high in the scene your touch is. I recommend doing it "relative to scene".

    Basically, you're looking for the angle to be calculated as a fraction of the screen height specified by the touch, if I understand you correctly. To create a fraction of the height, divide the height of the touch by the total height. To determine how far around the circle to rotate, multiply this fraction by the full circle, or 360 degrees.
  • jonnyDiamondjonnyDiamond Member Posts: 11
    Thanks msones!
  • mangaroomangaroo Member Posts: 419
    thanks indeed great learning tip
Sign In or Register to comment.