Hello,
I have a character that is 32 by 50. And I have tiles that are 32 by 32. I am creating the character like so:
cpShape *square = [smgr addRectAt:cpv(240,160) mass: 3.0 width:32 height:50 rotation:0];
character = [cpCCSprite spriteWithShape:square file:@"character_.png"];
cpCCSprite *character; //in header
Then after loading my tilemap I do this:
for(int x = 0; x < [collision layerSize].width; x++)
{
for(int y = 0; y < [collision layerSize].height; y++)
{
unsigned int tmpgid = [collision tileGIDAt:ccp(x,y)];
if(tmpgid == 34)
{
cpShape *collision_tile = [sm addRectAt:[collision positionAt:ccp(x,y)] mass:STATIC_MASS width:32 height:32 rotation:0];
//NSLog(@"gid: %i",tmpgid);
//NSLog(@"x: %f, y: %f ",tmp.x, tmp.y);
}
}
}
To add a cpShape that acts as a collidable object (ground or wall). The problem is the my character seems to sit below the ground or stops before he hits a wall. I was wondering if chipmunk needs some sort of offet to correct this problem?