I have a project where when I tap I check to see if the tap is on a specific node. If it is then I create a new SpriteNode at that position that is only visible for .1s before being deleted. I want to be able to spam tapping on the screen but with that current check the node that I end up tapping on is the new SpriteNode that I've created.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *touch in touches) {
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
if (node == shutdahellup){
[self runAction:[SKAction playSoundFileNamed:@"shut-da-hell-uh.mp3" waitForCompletion:NO]];
}else if (node == hotdamn){
[self runAction:[SKAction playSoundFileNamed:@"hot-damn.mp3" waitForCompletion:NO]];
}else if (node == wafflewednesday){
[self runAction:[SKAction playSoundFileNamed:@"waffle-wednesday.mp3" waitForCompletion:NO]];
}else if (node == damnwaffle){
[self runAction:[SKAction playSoundFileNamed:@"get-a-damn-waffle.mp3" waitForCompletion:NO]];
}
[self createFace:touch];
}
}
-(void) createFace:(UITouch *)touch {
SKSpriteNode * face = [SKSpriteNode spriteNodeWithImageNamed:@"shane.png"];
CGPoint location = [touch locationInNode:self];
face.position = location;
face.zPosition = 100;
[self addChild:face];
SKAction * wait = [SKAction waitForDuration:0.1];
SKAction * remove = [SKAction removeFromParent];
SKAction * sequence = [SKAction sequence:@[wait, remove]];
[face runAction:sequence];
}
Any ideas? Thanks!