Game Development Reference
In-Depth Information
Listing 13-1 . The BodySprite Header File
#import "cocos2d.h"
#import "Constants.h"
#import "Helper.h"
#import "PhysicsSprite.h"
#import "GB2ShapeCache.h"
@interface BodySprite : CCSprite
* Creates a new shape
* @param shapeName: Name of the shape and sprite
* @param inWorld: Pointer to the world object to add the sprite to
* @return BodySprite object
-(id) initWithShape:(NSString*)shapeName inWorld:(b2World*)world;
* Changes the body's shape
* Removes the fixtures of the body replacing them
* with the new ones
* @param shapeName name of the shape to set
-(void) setBodyShape:(NSString*)shapeName;
You use the initializer method initWithShape to initialize both the body and the
sprite by using the supplied shape name as defined in PhysicsEditor. It assumes that
both the name of the image and the name of the shape are identical.
Caution By default TexturePacker retains the file extension of images so that
your shape might be named “plunger,” but the sprite frame name might be
“plunger.png.” To fix that, you have to check the Trim sprite names check box
Search Nedrilad ::

Custom Search