Game Development Reference
In-Depth Information
can be removed from the Chipmunk space when the scene is deallocated. Chipmunk
doesn't automatically manage the memory of its physics objects the way Box2D does.
Because Chipmunk is a C library, ARC can't manage Chipmunk's memory either.
The initialization and dealloc part of HelloWorldLayer isn't much different from
the Box2D version, as you can see here:
#import "HelloWorldLayer.h"
#import "PhysicsSprite.h"
@implementation HelloWorldLayer
+(CCScene*) scene
CCScene* scene = [CCScene node];
HelloWorldLayer* layer = [HelloWorldLayer node];
[scene addChild:layer];
return scene;
-(id) init
self = [super init];
if (self)
self.isTouchEnabled = YES;
CGSize screenSize = [CCDirector sharedDirector].winSize;
CCLabelTTF* label = [CCLabelTTF labelWithString:@"Tap screen"
fontName:@"Marker Felt"
label.position = ccp(screenSize.width / 2, screenSize.height - 30);
[self addChild:label z:-1];
CCSpriteBatchNode* batchNode = [CCSpriteBatchNode ←
spriteTexture = batchNode.texture;
[self addChild:batchNode z:0 tag:kTagBatchNode];
Search Nedrilad ::

Custom Search