Search code examples
cocos2d-iphonebox2dbox2d-iphone

Collision between a sprite and a tilemap with Cocos2d and Box2d


I have the following map I made in Tiled, and then added to my project:

map = [[CCTMXTiledMap alloc] initWithTMXFile:@"FirstLevel.tmx"];
[self addChild:map];

I also have the following object which contains the player that I can move around:

objectLayer = [CCSpriteBatchNode batchNodeWithFile:@"level.pvr.ccz" capacity:150];
[self addChild:objectLayer z:10];

player = [[[Player alloc] initWithGameLayer:self] autorelease];
  [objectLayer addChild:[player ccNode] z:10000];
  [player setPhysicsPosition:b2Vec2FromCC(240,150)];

I can see my tilemap in the background, but it doesn't collide with anything. How can I make Player colide with the layers in my Tilemap?


Solution

  • Did it with Rubymotion and Joybox http://joybox.io/