Game Development Reference
In-Depth Information
Designing the Springboard
Right-click the
Prefabs
folder, and add a
New File
. Name it
Spring.ccb
, and set its type to
Node
before creating it.
From the
Tileless Editor View
, drag and drop the
springboard_spring
and
spring-
board_metal
images onto the stage. Make sure that
springboard_spring
is above
spring-
board_metal
in the Timeline. Then drag the
springboard_board
onto the
spring-
board_spring
in the Timeline so that the board becomes a child node of the spring. (See
Figure 9-17
.
)
Figure 9-17
.
The visual setup of the springboard
Select the
springboard_metal
, and set its position to
0x0
. Select the
springboard_spring
and change its position to
0x-16
, which will sink it into the base. Finally, select the
spring-
board_board
, and change its position types to
%
and change its values to
50
and
105
.
Note
A 50% X offset combats the effect of having child sprites centered on
their parent texture's lower left corner rather than on the parent's actual posi-
tion. It's an unfortunate design decision of Cocos2D from its early days. This
effect is best illustrated by adding several sprites, each a child of the previous
sprite. You'll notice the positions are such that each new child is positioned be-
low and to the left of its parent. Centering child sprites on their parent is best
done by adding a 50% offset because even though changing anchor point would
Search WWH ::
Custom Search