I’m having a lot of problems trying to draw body shapes on my sprites. I tried a lot of combinations but I’m not able to make it work on retina display.
I’m supporting iPhone retina only and both iPad (retina and not retina).
A. PTM_RATIO
The first question is which PTM_RATIO use for each device if I want the same physics in all devices. I read several posts and I don’t know if PTM stands for “Point To Meter” or “Pixel To Meter”.
¿Which column is the right one?
B. Physics
I want do draw a ground using different images of different shapes, but for this purpose I’m using two of the simplest type. An image of 200x200px but the body only takes the lower 200x80px rectangle.
To keep the sprite aspect I use 200x200px art for iPhone and iPad SD and 400x400 for iPad HD. Then I try to define a body for the red area. I tried all possible combinations using Physcs Editor and I tried to do it manually also with Vertex Helper. I made it work for iPad SD but not for retina display (always x2).
My verts:
int num = 4;
b2Vec2 verts[] =
{
b2Vec2(-100.0f / 100.0, -20.0f / 100.0), //A
b2Vec2(100.0f / 100.0, -20.0f / 100.0), //B
b2Vec2(100.0f / 100.0, -100.0f / 100.0), //C
b2Vec2(-100.0f / 100.0, -100.0f / 100.0), //D
};
I divided by 100 because I used the 200x200 art. I tried to divide by PTM_RATIO and by PTM_RATIO * CC_CONTENT_SCALE_FACTOR() without useful results. I tried to do it with the 400x400 art… I think I tried all the possible combinations.
For debugging purposes I’m using GLES-Render class provided with cocos2d+Box2d template.
The draw method in my layer:
- (void) draw
{
[super draw];
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
kmGLPushMatrix();
world->DrawDebugData();
kmGLPopMatrix();
}
Should I use?:
glScalef(CC_CONTENT_SCALE_FACTOR(), CC_CONTENT_SCALE_FACTOR(), 1);
I feel really stuck.
Edit:
Pysics Editor combinations and results:
Macro definition: 50 PTM_RATIO for iPhone and 100 PTM_RATIO for iPad 2 and iPad 3.