1

For example, let's say I have a block being hit with several balls. How would I make it so the function gets run when any ball hits the block? (as opposed to a singular ball hitting the block)

Essentially, I want this:

func ccPhysicsCollisionBegin(pair: CCPhysicsCollisionPair!, AllBalls[] nodeA: CCNode!, block nodeB: CCNode!) -> Bool {

    return true
}
Evan Conrad
  • 3,993
  • 4
  • 28
  • 46

1 Answers1

0

If all your balls are objects of a Ball class, you can set the collisionType property of the ball's physics body to ball.

For example:

func didLoadFromCCB() {
   physicsBody.collisionType = "ball"
}

Then, each ball object that you create will have that same collision type and the following function will be called whenever any of the balls collide with the block:

func ccPhysicsCollisionBegin(pair: CCPhysicsCollisionPair!, 
                             ball: CCNode!, block: CCNode!) -> ObjCBool {
        return true
    }
perror
  • 7,071
  • 16
  • 58
  • 85
Iavor
  • 1,997
  • 16
  • 27