Game Development Reference
In-Depth Information
// load physics definitions
[[GB2ShapeCache sharedShapeCache] addShapesWithFile:@"pinball-shapes.plist"];
// init the box2d world
[self initPhysics];
// load the background from the texture atlas
CCSprite* background = [CCSprite spriteWithSpriteFrameName:@"background"];
background.anchorPoint = ccp(0,0);
background.position = ccp(0,0);
[self addChild:background z:-3];
// Set up table elements
TableSetup* tableSetup = [TableSetup setupTableWithWorld:world];
[self addChild:tableSetup z:-1];
[self scheduleUpdate];
}
return self;
}
. . .
@end
The CCSpriteFrameCache loads the sprite frames from the texture atlas created
with TexturePacker by loading the pinball.plist file.
More importantly, this is followed by loading the pinball-shapes.plist file in-
to the GB2ShapeCache class . It is important to do this first before calling any
other Box2D method so that the shape cache's ptmRatio is correctly set to the value
from the PhysicsEditor setting PTM-Ratio. If you'll recall, PTM-Ratio was one of the
first PhysicsEditor settings you modified at the beginning of this chapter.
The pixel-to-meters macro PTM_RATIO used in Chapter 12 has been changed from a
simple constant value to the following definition, which you'll find in the Con-
stants.h header file:
Search Nedrilad ::




Custom Search