rotate a actor when is touched with two fingers?

hi,i need to rotate a actor but only when is touched by two fingers in the same time and both fingers are inside the actor, is this possible? right now all i can try is when touch is pressed and touch count=2, but with this , i can have 1 finger inside the actor and when i touch anywhere on the screen with a second finger then my actor rotates but both fingers are not inside.

Comments

  • MantoManto Member Posts: 796
    You'll have to use the touch1 and touch2 positions and check if they are inside the actor. And because the actor rotates, you'll have to use sin and cos functions.

    The corner points are:
    P1(actor.x+cos(rotation)*width/2, actor.y+sin(rotation)*height/2)
    P2(actor.x+cos(rotation)*width/2, actor.y-sin(rotation)*height/2)
    P3(actor.x-cos(rotation)*width/2, actor.y+sin(rotation)*height/2)
    P4(actor.x-cos(rotation)*width/2, actor.y-sin(rotation)*height/2)

    So you'll need to check if the touch1 and touch2 are inside that area.

    If you want me to make a demo file, let me know.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    In addition to the way @Manto1 described, you could also check to see if the distance of touch1 and of touch2 is less than some threshold value from the actor's center. That will give you a circular target area.
  • guillefaceguilleface Member Posts: 1,014
    thanks guys, @manto, i am only want to change its rotation plus +90 with two fingers, and not like rotating in circles, so maybe i dont need cos, sin? also how do i check if two fingers are inside? using the rule when touch is inside, that only counts for 1 right?
Sign In or Register to comment.