i have textures...
placeforjump = skspritenode(imagenamed: "placeforjump") placeforjump.position = cgpoint(x: 512.346, y: 98.88) placeforjump.size = cgsize(width: 166.407, height: 197.762) placeforjump.zposition = 2 self.addchild(placeforjump)
and character...
player = skspritenode(imagenamed: "character") player.position... player.size... player.zpozition = 3 self.addchild(player)
when touch texture can jump, want character jump on place, don't know how that.
when touch texture placeforjump - character jump on it.
please help.
you can detecting touch on place jump , when user touches can run action move character there.
to detect if user touches place jump can add code touchesbegan or touchesended functions:
for touch in touches { let location = touch.locationinnode(self) if placeforjump.containspoint(location) { print("it touched") } }
then run action place want use skaction this:
player.runaction(skaction.moveto(placeforjump.position, duration: speed)
this move player node placeforjump in shortes possible way if want go higher , place can this:
let highpoint = cgpoint(x: player.position.x + 50, y: player.position.y + 100) let moveup = skaction.moveto(highpoint, duration: speed) let movedown = skaction.moveto(placeforjump.position, duration: speed) player.runaction(skaction.sequence([moveup, movedown])
hope helps
Comments
Post a Comment