Game Development Reference
In-Depth Information
keyframe where the animation seems to “jump” to see if there's another key-
frame underneath it.
Keyframe Animations for Physics Nodes
Now that you know the basics of keyframe animations and how to edit them, you are
ready to add some animated game-play elements. The astonishing part here is that you'll
be animating nodes with physics enabled, and they'll behave properly in the game despite
being animated by actions.
However, keyframe animations of physics-enabled nodes are possible only if the node's
physics body is set to
Static
.
Adding the Gear and Saw
In SpriteBuilder's
File View,
select the
Sprite Sheets
folder. Right-click it to
create a
New Folder,
and name it
GameElements
. Right-click the
GameElements
folder, and select
Make Smart Sprite Sheet
. Optionally, you may want to change
the Sprite Sheet's publish format to the recommended
PVR RGBA8888
format with
Compress
selected.
In the topic's downloadable archive, you'll find an identically named
GameElements
folder, with
circularsaw1.png
and
gear1.png
files in it, among others. Drag and
drop all of the files in the
GameElements
folder from Finder onto the
GameElements
Sprite Sheet
in SpriteBuilder.
Now repeat the following steps twice, once for the gear and the other time for the circular
saw game element to create two new ccb files, named Gear1.ccb and Saw1.ccb.
1.
Right-click the
Prefabs
folder, and select
New File
.
2.
Name the document
Gear1.ccb
and
Saw1.ccb, respectively
, and
change its type to Node. I'll explain why it's a Node and not a sprite after
this list. Then click
Create
.
3.
Switch to
Tileless Editor View
. Open Gear1.ccb, and then drag and
drop the
gear1
onto the stage. Open Saw1.ccb, and drag and drop the saw1
onto the stage. Alternatively, you can drag the gear1.png and circu-
Search WWH ::
Custom Search