Game Development Reference
In-Depth Information
game in one second over a distance of 1024 points, the x velocity of that body would
have to be, you guessed it, 1024.
Give this a shot now. Publish, build, and run the project. You can now move the player in
a parabola curve. Up and down, up and down. Gravity keeps pulling the player down.
Tapping the screen will move the player upward and to the right. You can move over the
full extent of the level, but the player character can still leave the level's boundaries and
vanish.
Expose Design Values as Custom Properties
Now, about those temporary variable assignments. Remove the four lines shown in List-
ing 4-5 from the accelerateTarget: method.
Listing 4-5 . These variable assignments are no longer needed
// Temporary variables
_playerMaxVelocity = 350.0;
_playerNudgeRightVelocity = 30.0;
_playerNudgeUpVelocity = 80.0;
Note Keep the ivars declared just below the @implementation of the GameS-
ceneā€”the ones shown in Listing 4-1 . You'll still need those.
It's a good idea to make design parameters like the preceding one nudge and to make
maximum velocities editable in SpriteBuilder. This is especially true if you plan on doing
as little programming as possible, or if you want a nonprogramming person (sometimes
referred to as designer or artist ) to be able to modify design values.
To make custom properties editable in SpriteBuilder, go to SpriteBuilder and open the
GameScene.ccb . Then select the root node in the Timeline. If you look at the Item
Properties tab, you should see a horizontal divider that reads GameScene next to a
downward-pointing triangle. That triangle, by the way, allows you to expand and collapse
sections of properties, much like folders in Finder. Figure 4-2 shows the collapsed
CCNode properties section above the GameScene section, where you'll find the goal of
this exercise: the Edit Custom Properties button.
Search WWH ::




Custom Search