BOX2D has uses meters as a unit for length and width. However the objects need to be draw on screen in pixel sizes. The following macros helps with those conversions.

  1. #define PTM_RATIO 40.0f
  2. #define SCREEN_TO_WORLD(n) ((n) / PTM_RATIO)
  3. #define WORLD_TO_SCREEN(n) ((n) * PTM_RATIO)
  4. #define B2_ANGLE_TO_COCOS_ROTATION(n) (-1 * CC_RADIANS_TO_DEGREES(n))
  5. #define COCOS_ROTATION_TO_B2_ANGLE(n) (CC_DEGREES_TO_RADIANS(-1 * n))