Game Development Reference
In-Depth Information
Creating a Trigger CCB
What would be a good trigger node? Color nodes are arguably the best option, though in
general you can use any type of node. Trigger areas should be visible while editing but
see-through (transparent). The node color can be used to highlight different types of trig-
gers with different colors.
Once again, you should create the trigger object as a template. You should be familiar
with the process by now, so I'll keep the instructions short and to the point.
Create a
New File
in the
Prefabs
folder, name it
TriggerOnce.ccb
, and change its
type to
Layer
. The
Layer
type allows you to specify an initial size. It shouldn't be too
small or too large, and the actual size isn't that important—it will only determine the trig-
ger node's initial size in the level. A size of 128x128 works fine. Then click
Create
.
Note
The
Layer
type is important because it will give you a rectangular selec-
tion handle when placed in the level. You may have noticed that the saw and
gear instances have rotational selection handles. Rectangular selection handles
are simply easier to work with when you need to resize the node often, which
you'll need to do in order to adjust the trigger area's size and rectangular shape.
Drag and drop a
Color node
from the
Node Library View
onto the
Trigger-
Once.ccb
stage. On the
Item Properties
tab, set the position to 0, 0. Then change
the
Content size
type for both width and height to the same width and height of the
root node (128x128) so that the color node fills the layer's entire area. Also, pick a color
of your choice and set the opacity to 0.3—though the actual value doesn't matter. You
may want to come back later and change opacity and color to more appropriate values be-
cause this depends a lot on the graphics used, the number and size of trigger areas and,
above all, personal preference.
Note
You can also set the color node's
Content size
type to
%
and width
and height to 100 in order to fill the entire level. However, in the SpriteBuilder
version at the time of this writing, this would create a 1x1 sized polygon colli-
sion shape when enabling physics. Hence, I refrained from doing so. Both ways
are going to work equally well—after all, the size of the
TriggerOnce.ccb
layer and its color node doesn't need to be changed.
Search WWH ::
Custom Search