Game Development Reference
In-Depth Information
Getting ready
There are various shapes for the physics bodies that can be used to apply physics to a
scene. These shapes are defined as the personal space of the node. When the shape of one
node intersects with the shape of another node, the -didBeginContact method is in-
voked and physics may be applied. Now, to implement the collision detection, we will have
to understand the following properties of the physics bodies:
categoryBitMask : This property defines the category of the physics body. We
can have custom categories depending on our requirement. For example, in a war-
fare game, we can have player, bullets, and enemies as the categories. All the phys-
ics bodies can be based on these categories.
collisionBitMask : This property adds a mask that defines which physics
bodies can collide with this physics body. This will help the physics engine to eval-
uate and throw only the required results in the delegate methods. For example, the
bullets can only collide with enemies, not with any player.
contactTestBitMask : This property defines the mask to specify which cat-
egories of physics bodies cause intersection notifications with this physics body.
Search WWH ::




Custom Search