ios - Border collision detection -


i'm making game sprite kit , have collision detection setup this:

    ball.physicsbody?.categorybitmask = ballcategory     borderbody.physicsbody?.categorybitmask = bordercategory 

and handler -didbegincontact():

func didbegincontact(contact: skphysicscontact) {      var firstbody = skphysicsbody()     var secondbody = skphysicsbody()      if contact.bodya.categorybitmask < contact.bodyb.categorybitmask {         firstbody = contact.bodya         secondbody = contact.bodyb     }else {         firstbody = contact.bodyb         secondbody = contact.bodya     }      if firstbody.categorybitmask == ballcategory && secondbody.categorybitmask == bordercategory {         print("you lose!")     }  } 

i have line set contact delegate:

self.physicsworld.contactdelegate = self 

but when run game, collision not detected , nothing happens. wrong?

see documentation here. need set contacttestbitmask if want receive contact/intersection notifications. unlike collisionbitmask default value 0xffffffff, default value contacttestbitmask 0x00000000.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -