ios - SpriteKit - Stop Clicks on Sprite From Acting Upon Children -


i use following create button text using spritekit:

sklabelnode *startbuttontext = [sklabelnode labelnodewithfontnamed:@"verdana-bold"]; startbuttontext.text = @"start"; startbuttontext.fontcolor = [skcolor colorwithred:1 green:1 blue:1 alpha:1]; startbuttontext.fontsize = 24; startbuttontext.position = cgpointmake(self.size.width/2, self.size.height/2-10); startbuttontext.name=@"startbutton";  skshapenode *startbutton = [[skshapenode alloc] init]; startbutton.path = [uibezierpath bezierpathwithrect:cgrectmake(center.x-65.0 , center.y-20.0, 130.0, 40.0)].cgpath; startbutton.fillcolor = [skcolor colorwithred:0.188 green:0.196 blue:0.161 alpha:1]; startbutton.strokecolor = nill; startbuttontext.name=@"startbutton";  [startbutton addchild:startbuttontext]; [self addchild:startbutton]; 

my goal make when screen touched, touch registers startbutton not start startbuttontext via:

- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event {     uitouch *touch = [touches anyobject];     cgpoint location = [touch locationinnode:self];     sknode *node = [self nodeatpoint:location];     nslog(@"%@",node.name); } 

in action script, use:

mousechildren = false; 

is there anyway possible?

give both buttons different name. looks there's copy & paste error in code. check in touchesbegan button has been pressed , react on both same way:

if ([node.name isequaltostring:@"startbutton"]||[node.name isequaltostring:@"startbuttontext"]) { ... } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -