Game Development Reference
In-Depth Information
CCDirector extensions like currentPlatformIsIOS and currentPlat-
formIsMac .
Listing 16-6 . Updating the Player's Velocity
-(void) acceleratePlayerWithX:(double)xAcceleration
// adjust velocity based on current accelerometer acceleration
playerVelocity.x = (playerVelocity.x * deceleration) + ←
(xAcceleration * sensitivity);
// we must limit the maximum velocity of the player sprite, in both directions
if (playerVelocity.x > maxVelocity)
playerVelocity.x = maxVelocity;
else if (playerVelocity.x < −maxVelocity)
playerVelocity.x = −maxVelocity;
Everything else requires no changes to create the Mac OS port, thanks to the fact that
no hard-coded positions and offsets were used. Nevertheless, it makes sense for game
play reasons to restrict the Mac window size to that of an iPhone in config.lua :
WindowFrame = RectMake(300, 300, 320, 480),
The Lua function RectMake creates a rectangle with the given origin (300, 300) and
size (320, 480). RectMake creates rectangles that are compatible with CGRect or
NSRect , depending on the platform. Additional Lua utility functions are PointMake
and SizeMake .
Search Nedrilad ::

Custom Search