Game Development Reference
In-Depth Information
larsaw1.png from the GameElements Sprite Sheet onto the respective stages.
There should now be a gear sprite in Gear1.ccb and a saw sprite in
Saw1.ccb.
4.
On the
Item Properties
tab, set the gear/saw sprite's position to 0, 0.
Leave the anchor point at 0.5, 0.5. This ensures the gear/saw sprite is
centered on its pivot point when placed in the level.
5.
Switch to the
Item Physics
tab. Select the
Enable physics
check box
.
Change the body type to
Static
. Leave
Categories
and
Masks
empty.
6.
In the
Collision type
field, enter
gear
when editing the gear object, and
saw
when editing the circular saw object.
7.
Only for the gear sprite: leave the
Physics shape
drop-down menu set to
Polygon
. Edit the Polygon shape as explained in
Chapter 4
so that the
polygon outline coarsely matches the gear and its gear teeth as shown in
Fig-
Figure 5-6
.
Gear polygon shape and properties
8.
Only for the saw sprite: change the
Physics shape
drop-down menu to
Circle
. Change the suggested radius from 208 to 190, about 10% smaller.
Remember how I mentioned earlier that root nodes typically can't be animated, and only
CCSprite
root nodes can animate a few visual properties: sprite frames, opacity, and
color?
That's why I didn't use a Sprite CCB document but instead chose to use a Node CCB doc-
ument with a sprite as child node. That way, you can fully animate the sprite within the
Search WWH ::
Custom Search