Dobroćudni Tapir
Dobroćudni Tapir

Reputation: 3102

Handling touch without consuming it

I need to handle the touch and not consume it. Is it possible to perform in SpriteKit? I would like to keep code as generic as possible.

Following the documentation I tried this:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    //Do some work with the touch

    //Forward it to next responder(node bellow)
    [super touchesBegan:touches withEvent:event];
}

But touches don't get forwarded.

My class is subclass of SKNode.

Upvotes: 0

Views: 405

Answers (1)

CodeSmile
CodeSmile

Reputation: 64478

Simple:

[self.parent touchesBegan:touches withEvent:event];

The next responder is always another view, not another node. If the direct parent is not the node you want to send it to, then do self.parent.parent or self.parent.parent.parent if you know that the right node is the n-th parent of the node receiving the touch. Otherwise use the node search functionality to find the right node.

Upvotes: 1

Related Questions