Calculate touch drag distance before releasing?

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

This is a tricky one to explain , but I will do my best.

I have an actor that I want to control its rotation with, by touch and dragging on the y axis.

I currently have it working by calculating game.touch.Y and converting it into an angle.

But my problem is that I want the drag to add to the actors rotation angle as apposed to just changing angle.

I want the touch gesture to be like a scrolling action. The more you flick upwards, the more the actor rotates. Like the difference between using a mouse to a wacom tablet(if you know what I mean?).

So, what I think I need to do is to continually measure the distance of the drag from the first game.touch.Y to where ever the game.touch.Y moves too (not released) - then convert this distance to an angle - then use that to add to the actors angle.

It is important that it adds to the actors angle (accumulative) as apposed to just changing it.
Also, it is important that I constantly measure the distance - So not just on release.

Any ideas?

Thanks for your help.

Comments

  • SquareHeartSquareHeart Member, PRO Posts: 69
    I know what you're trying for. I posted a similar question a month ago (but was xy coords rather than angle) and got no answer - it's a hard one to describe. I had a map that I wanted the player to be able to scroll around (and pinch zoom) I too couldn't figure out how to add to the movement values rather than just snap/constrain to them - this is especially annoying when trying to scroll around... Lets keep bumping this, someone must have an idea!
  • m456arcusm456arcus Member Posts: 189
    I may be wrong here, but for johnny, you would calculate the angle that the player flicks or drags using VectorToAngle with the correct offsets, constrain an attribute to that, and then add that to the main actor's current rotation. Freerby, I believe it would be the same for you, just replace VectorToAngle with Magnitude. Beyond that, I'm sure there's a template or demo for your exact situation.
Sign In or Register to comment.