sprite kit - Checking for collision in SWIFT -
i have 2 objects want collide: ball , centerblock. created physics bodies each , wrote following:
ball.physicsbody!.categorybitmask = bodytype.ballcategory.toraw() ball.physicsbody = skphysicsbody(circleofradius: ball.size.height / 2) ball.physicsbody!.dynamic = false ball.physicsbody!.collisionbitmask = bodytype.ballcategory.toraw() | bodytype.centerblockcategory.toraw() ball.physicsbody!.contacttestbitmask = bodytype.centerblockcategory.toraw() centerblock.physicsbody!.categorybitmask = bodytype.centerblockcategory.toraw() centerblock.physicsbody = skphysicsbody(rectangleofsize: centerblock.size) centerblock.physicsbody!.dynamic = false
now not sure write in didbegincontact method check if 2 objects collided. not experienced spritekit or swift have nil written in method. want observe when 2 collide because supposed end game. thanks!
swift sprite-kit xcode6 collision-detection bitmask
No comments:
Post a Comment