Game Development Reference
in the TexturePacker Output pane. The pinball.tps file used in this chapter
has this check box already set; it removes the .png extension from the sprite
frame names. That way, both the TexturePacker sprite frames and PhysicsEditor
shape names will be identical.
For the texture atlas, you use TexturePacker and add the pinball folder as a smart
folder reference, meaning that TexturePacker will keep the texture atlas contents up to
date with all changes to the images in the pinball folder. Refer to Chapter 6 for in-
structions on how to set up a smart folder reference.
You also need to set an additional option you haven't used yet: trim sprite names. This
feature removes the .png suffix from the sprite names. The advantage is that you can
use the same names for the physics shapes and the sprites. The only caveat is that
you'll have to refer to sprite frame names without the .png extension, which admit-
tedly out of habit is sometimes easy to forget.
Listing 13-2 shows the BodySprite class implementation file.
-(id) initWithShape:(NSString*)shapeName inWorld:(b2World*)world
// init the sprite itself with the given shape name
self = [super initWithSpriteFrameName:shapeName];
// create the body
physicsBody = world- > CreateBody(&bodyDef);
physicsBody- > SetUserData((__bridge void*)self);