sprite kit - How to set the location of a tap -


i want set game when user taps specific point on screen dispenses skspritenode location. i've set inside touches began method:

for (uitouch *touch in touches) {     score = score + 1;      cat = [skspritenode spritenodewithtexture:[sktexture texturewithimagenamed:@"cat.png"] size:cgsizemake(35, 35)];     cat.position = cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidy(self.frame)+120);      [self addchild:cat]; } 

which works fine , adds node touch occurred.

i want added when user touches specific location, tried setting up:

for (touch locationinnode:cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidy(self.frame)) {     score = score + 1;      cat = [skspritenode spritenodewithtexture:[sktexture texturewithimagenamed:@"cat.png"] size:cgsizemake(35, 35)];     cat.position = cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidy(self.frame)+120);      [self addchild:cat]; } 

but didn't work , told me needed square bracket ] reason.

how can set spawns if user touches middle of screen?

i think can use

-(void) touchesbegan:(nsset *)touches withevent:(uievent *)event{         uitouch* touch = [touches anyobject];         cgpoint positioninscene = [touch locationinnode:self];         // add logic check specific location          // if( cgpointequaltopoint (positioninscene, yourspecificposition)          // render cat     } 

hope help


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -