Game Development Reference
In-Depth Information
Now open the
TriggerOnce.ccb
, and repeat the process for any additional triggers you
may have created, such as the
TriggerForever.ccb
. Select the
CCNodeColor
node to edit
its
Item Physics
properties.
Enter
trigger
in the
Categories
field and
player
in the
Masks
field. This ensures that the
player can collide with triggers, since the player already has
trigger
in its collision mask
and the trigger now has the player in its collision mask as well. Collisions occur only
when both participants have each other's category in their
Masks
field, or when the
Masks
field is empty for at least one participant.
The borders are edited in the same way, except you'll find multiple border CCB files un-
der
Prefabs/Borders
, starting with
Border1.ccb
. You need to open each border CCB and
in the its root node's
Categories
field enter
border
and in its
Masks
field enter
player
. This
ensures that all border sprites continue to be impenetrable collisions for the player.
Finally, and this is where it gets tedious, you need to edit each physics-enabled node in
both
Chain.ccb
and
Rope.ccb
to update their categories and masks. In each physics-en-
abled node's
Categories
field, enter
obstacle
, and in its
Masks
field enter
player, obstacle
to make the chain or rope collide with the player as well as other chains and ropes. Again,
note that the items must be comma-separated to create separate labels, as you saw on the
right side of
Figure 9-15
.
Tip
You may want to enter the
Masks
text once, ensure that it is correct, and
then select the labels either by clicking in the field and pressing Cmd+A or by
using text selection. To use text selection, drag the mouse from one end of the
text to the other. The labels are drawn in a dark blue color when selected. You
can then press Cmd+C to copy and Cmd+V to paste the labels in another node's
Masks
field. That way, you can reduce the risk of creating a typo.
If you forget to edit one chain or rope element's categories or masks, that element might
still collide with the player. To ensure correctness, verify the categories and masks once
you are done editing.
Select the first node in the Timeline; this will most likely be the static
hook
node. Look at
its
Item Physics
tab, and confirm that the
Categories
and
Masks
are correct. Now press the
down arrow key to select the next node in the Timeline. By repeatedly pressing the down
arrow key, you can quickly verify the collision and other settings of a series of nodes. It
definitely beats clicking each node with the mouse.
Good. Now that all the physics nodes in
Chain.ccb
and
Rope.ccb
have their categories and
masks set, you can give this a try.
Search WWH ::
Custom Search