Game Development Reference
In-Depth Information
Static bodies do not collide with other static bodies. Two Gear1.ccb in-
stances could not be made to collide, for instance.
Both bodies must have the same CCPhysicsNode as their parent (or grand-
parent or great grandparent, etc.).
Although you can have multiple CCPhysicsNode instances in a scene,
they represent completely separate physics worlds. There is absolutely no in-
teraction between two CCPhysicsNode instances possible.
Enable physics debug drawing to confirm that the collision shapes, in fact,
do overlap. The collision shapes can be very different from the images the
node draws. Merely looking at the sprites is sometimes not enough to assess
the situation.
Verify that the shapes are correctly set up without self-intersecting lines.
Select the node, switch to the Item Physics tab, and look for any lines high-
lighted in red.
Bodies connected with at least one joint will default to not collide with each
other, unless the corresponding Collide bodies flag is checked on the joint.
A Node Is Not Deallocating
Sometimes you determine that a node or the entire scene doesn't deallocate when you ex-
pect it to. You can verify this by using Instruments (an Xcode tool for runtime analysis
and profiling) and looking at the live objects, or quite simply by implementing the
-(void) dealloc method and testing with an NSLog or breakpoint whether the meth-
od runs or not. If it doesn't, the object is still in memory.
The reason for this is often quite simple, yet it can be difficult to track down because it all
depends on where pointers to that object have been stored or where they have been as-
signed to. Here are a few things to consider:
Any object assigned to an ivar or property defaults to being kept in memory
(retained) as long as the reference is not set to nil . This is said to be a
strong reference . Most ivars in the topic project are declared as __weak to
allow them to be deallocated when they are removed from the node graph.
As long as a node is part of the node graph (i.e., it is active in the current
scene), the node is retained by its parent's children array.
Search WWH ::




Custom Search