Question

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.

Was it helpful?

Solution

It looks like i simply needed to do a

[[event allTouches] count]

to actually get the touch count.

OTHER TIPS

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
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top