objective c - Can't tap SKSpriteNode - no touch detected ios -
I'm fairly new to working with iOS, Objective-C and Xcode. I have just created a simple news type app, but now I would like to create a game that I had published on any other platform.
Actually, I have an object that will appear randomly and then it will be fade out and its purpose is to tap it on the object to move it away.
Although I can not tap the object, even if I have mySKSpriteNode.userInteractionEnabled = YES;
In my touchesBegan
method this is:
- (zero) touches: (NSSET *) touches the avenues Is: (UIEvent *) event {/ * when a touch begins * / NSLog (@ "something touched"); UIT * touch = [touches any object]; NSLog (@ "% @", touch); CGPoint Location = [Touch Position InDude: Self]; SKNode * node = [self nodepointpoint: location]; If (node == mySKSpriteNode) [node run action: [skeleton fadeout with aperture: 0]]; }
In my logs, I get it when I tap the screen (where I am not an object):
2014-02- 17 23:18: 30.870 Bubble Challenge [48541: 70b] Some Things 2014-02-17 23:18 18: 30.875 Bubble Challenge [48541: 70b] & lt; UIT: 0x1130ea530 & gt; Step: Getting started Tap number: 1 Window: & lt; UIWindow: 0x109c2ab60; Frame = (0; 320 568); Autoresiz = wh; H; Line writer = & lt; NSArray: 0x109c274d0 & gt; Layer = & lt; UIWindowLayer: 0x10 9c26810 & gt; & Gt; See: & lt; SKView: 0x109c2e5e0; Frame = (0; 320 568); Autoresc = RM + BM; Layer = & lt; CAEAGLLayer: 0x109c0e180 & gt; & Gt; Location in the window: {147.5, 128.5} Previous location in window: {147.5, 128.5} To see the location: {147.5, 128.5} In the previous location view: {147.5, 128.5}
When
Why is any thoughts happening?
I found that the answer to the other questions is to set userInteractionEnabled = YES
.... The code may have a specific point where I should set it ... .
All help is appreciated!
Have you tried setting the property of your spitinode name
?
For your mySKSpriteNode
in the beginning:
mySKSpriteNode = [[SKSpriteNode alloc] initWithTitxture: sometiexture]; MySKSpriteNode.name = @ "ISMIsprint ITE"; // Set the name for your phantom mySKSpriteNode.userInteractionEnabled = NO; // user interface must be enabled
then:
- (zero) touches: touches the (NSASE *) event: (UIEvent * ) Event {UITouch * touch = [touches an object]; CGPoint Location = [Touch Position InDude: Self]; SKNode * node = [self nodepointpoint: location]; If ([node name is excelstostring: @ "ISMIS pratiktak"]) {NSLog (@ "ISKspract node was touched!"); [Node run action: [graduation fadeout with duration: 0]]; }}
Comments
Post a Comment