Game Development Reference
In-Depth Information
sprite.position = CGPointMake(screenSize.width / 2, screenSize.height / 2);
Of course, once you create an iPad version of this project, the images won't fit per-
fectly anymore because they were designed for a screen of 960 × 640 resolution. To
create an iPad version, follow the exact same steps except make your original image
1024 × 768 in size, or even double that if you also want to support Retina iPad resolu-
tions. You can then downscale the 960 × 640 images from the higher resolution images
easily just by cropping the borders.
Tip It takes surprisingly little effort to re-create the source image from indi-
vidual sprite frames in cocos2d, and it's all thanks to TexturePacker saving the
image offsets for you. It's also a great way to create your game screen layouts.
You can have an artist design each screen as separate layers, as many as needed,
using the native screen resolution (960 × 640 for iPhone and 2048 × 1536 for
iPad). Then export each layer as an individual full-screen file with transparency.
Next create a texture atlas from these files and you'll have the artist-envisioned
screen design in cocos2d with no hassle of positioning individual files and no
wasted memory either. TexturePacker takes care of scaling down the images to
standard resolution, if needed.
Because the ParallaxBackground class is derived from CCNode , you only need
to add it to the GameLayer init method after the sprite frames are loaded to add
the ParallaxBackground to the game, like this:
-(id) init
if ((self = [super init]))
sharedGameLayer = self;
// if the background shines through we want to be able to see it!
glClearColor(1, 1, 1, 1);
// Load all of the game's artwork up front.
CCSpriteFrameCache* frameCache = [CCSpriteFrameCache sharedSpriteFrameCache];
[frameCache addSpriteFramesWithFile:@"game-art.plist"];
Search Nedrilad ::

Custom Search