ios - Sprite Kit Select SKNode below another SKNode -
i'm creating ios app sprite kit & i'm trying select (ontouchbegan) sknode lies below sknode. structure : firstlayer(sknode) - secondlayer(sknode) & 3rd layer (sknode). i'm trying select secondlayer , move around ontouchmove. current problem touch recognises 3rdlayer. can me ?
to elaborate on scott's comment, zposition
property of sknode
layer lies on, higher layer numbers being "closer" front of screen. therefore if want have nodeb
on top of nodea
, nodea
have zposition
higher number of a, such as:
nodea.zposition = 1 nodeb.zposition = 2
if set zposition
of node when create it, can set conditional check on zposition of touched node in 'touchesbegan' method. following above example, if touch nodea
, notnodeb
, check zposition
of node being touched equal 1
:
-(void)touchesbegan:(nsset *)touches withevent:(uievent *)event{ uitouch *touch = [[event alltouches] anyobject]; cgpoint location = [touch locationinnode:self]; sknode *node = [self nodeatpoint:location]; if(node.zposition == 1){ //do stuff nodea here } }
i think scott getting at, hope helps.
Comments
Post a Comment