I am pretty new to iOS, objective C and working with Xcode. I only did one simple news type app, but now I would like to create a game I had published on another platform.>
Your code is essentially correct. Just a few minor changes are required.
You have implemented the -touchesBegan:
method in your scene class. If you want to handle touches from within the scene class, then all the child nodes should have the userInteractionEnabled
property set to NO
. A sprite node's userInteractionEnabled
property should be set to YES
only when it is capable of handling touches on it's own.
So, in your case you should make the following changes:
1 - Set the spriteNode's userInteraction to NO.
mySKSpriteNode.userInteractionEnabled = NO;
2 - Change the way you check for your own sprite.
if([node isEqual: mySKSpriteNode])
You will find your code is working as intended.