swift - Splitting touchesMoved across a single SKSpriteNode -


using spritekit, have created skspritenode called lightsaber, , using touchesmoved method, able either rotate skspritenode or translate left or right. there way make 1 or either depending on grab skspritenode? (e.g. blade or handle)

you position of touchevent via

cgpoint location = [touch locationinnode:self]; 

this give capability add custom logic touch screen. example:

if(location.x > 300) {    //do } else {    //do } 

you make sword in 2 pieces, i.e 2 nodes , name each node , listen touch event on both nodes.

get node within touchesbegan by

sknode *node = [self nodeatpoint:location]; if([node.name isequaltostring@"handle"]) {  } else if ([node.name isequaltostring@"blade"]) {  } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -