Game Development Reference
In-Depth Information
Figure 10-4 . The circumference physics bodies and their circle shapes highlighted through physics debug
drawing
If any two circumference bodies in a soft-body physics object overlap or touch, the entire
soft-body will be in constant unrest. If the gap is too wide, however, other bodies (both
those on the soft-body object itself and external bodies such as the chain and rope ele-
ments) may too easily pass in between the soft-body's outer bodies, thus causing the soft
body to become stuck.
Figure 10-4 also illustrates how the circumference bodies enlarge the player's actual colli-
sion radius. You'll later accommodate this by simply drawing the player's texture using
the larger radius, effectively scaling it up.
Moving and Drawing the Soft-Body Player
If you run the current state of the project with physics debug drawing enabled, you'll no-
tice the player's circle bodies falling down, and no more. The player sprite itself remains
at its original location, and you can't move the player either because the sprite itself no
longer has a physics body. You will have to apply the movement force to all bodies
equally, and you'll have to use the center node as the new player node.
Moving the Soft-Body Player
The movement changes are quickly implemented. In Xcode, open GameScene.m to add a
new BOOL ivar named _softBodyPlayer that allows you to make the code backward-
Search WWH ::




Custom Search