swift - Moving Sprites along a path, while being affected by gravity -


i have tower sprite skshapenode around it, , monstersprite. monster sprite affected gravity can detect contact towersprite's skshapenode , monstersprite.

this towersprites skshapenode, , did similar thing monster(but dynamic yes):

self.towerrangenode.physicsbody = [skphysicsbody bodywithcircleofradius:100]; self.towerrangenode.physicsbody.dynamic = no; self.towerrangenode.physicsbody.categorybitmask = physicscatagorytower; self.towerrangenode.physicsbody.collisionbitmask = 0; self.towerrangenode.physicsbody.contacttestbitmask = physicscatagorymonster | physicscatagorytower; self.towerrangenode.physicsbody.usesprecisecollisiondetection = yes; 

then when add monster, make follow path this:

// creates path monster follow cgmutablepathref monsterpath = cgpathcreatemutable(); cgpathmovetopoint(monsterpath, null, 0, 0); cgpathaddlinetopoint(monsterpath, null, 310, 0); cgpathaddlinetopoint(monsterpath, null, 310, -65); cgpathaddlinetopoint(monsterpath, null, 12, -65); cgpathaddlinetopoint(monsterpath, null, 12, -130); cgpathaddlinetopoint(monsterpath, null, 350, -130);  skaction *path = [skaction followpath:monsterpath asoffset:yes orienttopath:no duration:15]; [monster runaction:path]; 

so expect happen is, monster moves along path, , if collides tower's skshapenode, notified, monster falls off screen, , doesn't follow path, if skshapenode in falling path, still detects it.

i monster moves along path, while being able detect contact skshapenodes, , not fall off screen

thanks


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -