I am trying to make a physics world using CCPhysicsNode for a game (physics will be used to bullet collision detection). The debug drawing for the physics bodies are off where they actually are. I believe this may be due to having a CCNode as parent of the physics world, and the CCNode follows the player sprite (game world is larger than screen). Here is the relevant code:
_controlLayer = [CCNode node];
_controlLayer.position = ccp(0, 0);
_gameLayer = [CCNode node];
[self addChild:_gameLayer];
[self addChild:_controlLayer];
_physicsWorld = [CCPhysicsNode node];
_physicsWorld.debugDraw=YES;
_physicsWorld.collisionDelegate = self;
[_gameLayer addChild:_physicsWorld];
[self setupMap];
[self setUpControls];
[self setupPlayer];
_allZombies = [[NSMutableArray alloc]init];
[_gameLayer runAction:[CCActionFollow actionWithTarget:_player worldBoundary:_map.boundingBox]];
-(void)setupPlayer {
_player = [CCSprite spriteWithImageNamed:@"Player.png"];
_player.position = CGPointMake(1024/2+60,768/2+60);
_player.anchorPoint = ccp(0.5, 0.5);
_player.physicsBody = [CCPhysicsBody bodyWithRect:_player.boundingBox cornerRadius:0];
_player.physicsBody.elasticity = 0;
_player.physicsBody.sensor=YES;
_player.physicsBody.collisionGroup = @"playerGroup";
_player.physicsBody.collisionType = @"playerCollision";
[_player setScale:0.5];
[_physicsWorld addChild:_player];
}
So my question is, why is the drawing off where the player sprite is?