ios - Not getting any movement from sprite in Sprite Kit -
ios - Not getting any movement from sprite in Sprite Kit -
i trying move sprite node downwards every time touch in area. code have , log showing touches register. doing wrong , there easier way accomplish this?
-(void)update:(cftimeinterval)currenttime {      cgpoint currentlocation = [currenttouch locationinview:currenttouch.view];      if (currentlocation.y > 500) {       cgfloat newy = _bg.position.y - 25;     _bg.position = cgpointmake(_bg.position.x, newy);     nslog(@"touchtouch"); }       
try this:
-(void)touchesbegan:(nsset *)touches withevent:(uievent *)event {  (uitouch *touch in touches) {  cgpoint currentlocation = [touch locationinnode:self];  if (currentlocation.y > 500) {       cgfloat newy = _bg.position.y - 25;     _bg.position = cgpointmake(_bg.position.x, newy);     nslog(@"touchtouch");       }    } }    you can  utilize skaction have  motion animated:
skaction *movedown = [skaction movetoy:newy duration:1];     [_bg runaction:movedown];    hope can help you!
 ios objective-c position sprite-kit sprite 
 
Comments
Post a Comment