xcode - Determine When SpriteNode Is Landed On A Rectangle SpriteNode -


i making game there clouds moving, , want clouds fade away when character lands on it. however, when put code, fades away if character goes around , hits bottom or side of cloud while still falling. here code have detecting when character , cloud have hit.

is there anyway determine when character has landed on top of cloud not fade cloud away if hits bottom or side while falling?

here code declaring objects:

    person.physicsbody?.usesprecisecollisiondetection = true     person.size = cgsizemake(self.frame.size.width / 25, self.frame.size.height / 16.25)     person.physicsbody = skphysicsbody(rectangleofsize: person.size)     person.physicsbody?.restitution = 0     person.physicsbody?.friction = 0     person.physicsbody?.allowsrotation = false     person.physicsbody?.affectedbygravity = true     person.physicsbody?.dynamic = true     person.physicsbody?.lineardamping = 0     person.zposition = 5     person.physicsbody?.categorybitmask = bodytype.personcategory.rawvalue     person.physicsbody?.contacttestbitmask = bodytype.cloudcategory.rawvalue     person.position = cgpoint(x: cgrectgetmidx(self.frame), y: cgrectgetmidy(self.frame) * 1.7)     self.addchild(person)       cloud = skspritenode(texture: normalcloudtexture)     cloud.zposition = 7     cloud.physicsbody?.usesprecisecollisiondetection = true     cloud.physicsbody?.affectedbygravity = false     cloud.physicsbody?.allowsrotation = false     cloud.size = cgsizemake(self.frame.size.width / 8.05, self.frame.size.height / 40)     cloud.physicsbody = skphysicsbody(rectangleofsize: cloud.size)     cloud.physicsbody?.friction = 0     cloud.physicsbody?.restitution = 0     cloud.physicsbody?.dynamic = false     cloud.position = cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidy(self.frame) / 7.60)     addchild(cloud) 

here code when objects have hit:

func didbegincontact(contact: skphysicscontact) {       let contactmask = contact.bodya.categorybitmask | contact.bodyb.categorybitmask      switch(contactmask)     {     case bodytype.personcategory.rawvalue | bodytype.cloudcategory.rawvalue:         jumpcontact = true         let checkdelay = delay(0.055)             {                      //cloud fades away here          } 

i have not done it, have idea. :)

i think should do: track contact position contactpoint property , check if not touching x position of cloud lower few points top.

i hope helps you. :)


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -