Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for i = 0; i<1000; ++i {
- var randomNumber = CGFloat(arc4random_uniform(3000)) * 200
- bubbleDuplicate.position = (CGPointMake(randomNumber, 400))
- bubbleDuplicate = bubble.copy() as! SKSpriteNode
- bubbleDuplicate.physicsBody?.categoryBitMask = bubbleCategory
- bubbleDuplicate.physicsBody?.collisionBitMask = 0
- bubbleDuplicate.physicsBody?.contactTestBitMask = 0
- addChild(bubbleDuplicate)
- func BubbleContact(){
- bubbleDuplicate.removeFromParent()
- bubble.removeFromParent()
- bubbleDuplicate.setScale(0)
- bubble.setScale(0)
- }
- }
- func didBeginContact(contact: SKPhysicsContact) {
- let collision:UInt32 = (contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask)
- if collision == (playerCategory | crateCategory) {
- gameOver()
- }
- if collision == (playerCategory | bubbleCategory) {
- NSLog("Bubble Contact")
- bubbleDuplicate.removeAllActions()
- bubbleDuplicate.removeFromParent()
- bubble.removeAllActions()
- bubble.removeFromParent()
- bubbleDuplicate.setScale(0)
- bubble.setScale(0)
- bubbleDuplicate.alpha = 0
- bubble.removeFromParent()
- bubbleDuplicate.removeFromParent()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement