Game Development Reference
In-Depth Information
The center body is easy. Drag and drop a node from the Node Library View onto the stage.
Edit the node's position to 32x32 so that it is centered on the player image. Then switch to
the Item Physics tab, and check the Enable Physics check box. Change the shape type to
Circle , and set the Corner radius to 10 . Also, uncheck Allows rotation .
Note Individual bodies of the soft body needn't and shouldn't rotate around
their own axis. Any rotation will come from the combined force applied to the
body as a whole, distributed through body-to-body collisions and, of course, the
joints.
Now edit the callback and collision properties. The Collision type should be set to player ,
and likewise enter player in the Categories field, too. In the Masks field, enter (without
quotes): “ trigger, border, obstacle, spring, player ”. Notice that player is now part of the
mask because the individual bodies making up the player's new soft body should also col-
lide with each other, both to distribute force to one another as well as prevent circumfer-
ence bodies from being pushed into or past the center body.
With the center node selected, copy (Cmd+C) and paste (Cmd+V) the node eight times so
that you get a total of nine nodes, each with physics enabled and the same properties as
the initial node. You may want to rename the first node in the Timeline to center so that
you know which one the center node is. This is crucial because the code you're about to
write assumes that the center node is the first of the root node's children. If that isn't the
case, you can drag the node in the Timeline to reorder it.
You should also rename the other nodes in the Timeline as well, to highlight their position
on the circle. The following description assumes the first node is on the right and the
nodes will be arranged in clockwise direction. Therefore, the node names ought to be:
right , bottom-right , bottom , bottom-left , left , top-left , top , top-right . See Figure 10-2 to see
what the SoftBodyPlayer.ccb 's Timeline should look like now.
Search WWH ::




Custom Search