Reputation: 2292
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.
Upvotes: 1
Views: 882
Reputation:
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
}
}
Upvotes: 1
Reputation: 2292
It looks like i simply needed to do a
[[event allTouches] count]
to actually get the touch count.
Upvotes: 3