문제

Using spritekit, in the touchedEnded event, is there a way to determine the number of touch points for that event?

I would like to know the number of touch points (single, double, triple - one finger, two fingers or three fingers) were used to fire this event, and i will need to perform a different action based on each type of touch (normal movement for a single point touch, double speed for two finger touches, and a jump to action for three finger touches).

I have the even operational with a single point touch, just need to know to identify a multi touch gesture, and perhaps, how to enum them.

도움이 되었습니까?

해결책

It looks like i simply needed to do a

[[event allTouches] count]

to actually get the touch count.

다른 팁

You could also use a UITapGestureRecognizer and set the numberOfTouchesRequired to your desired finger count.

In your SKScene:

- (void)didMoveToView:(SKView *)view 
{
    UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerTap:)];
    tapRecognizer.numberOfTouchesRequired = 2;    
    [[self view] addGestureRecognizer:tapRecognizer];
}

- (void)handleTwoFingerTap:(UITapGestureRecognizer *)sender
{
    if (sender.state == UIGestureRecognizerStateEnded)
    {
        // your code
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top