Breaking News
Home / iOS / iOS Snippets / Some useful Box 2D macros

Some useful Box 2D macros

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))
[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger