Impulses when in retina mode

Hi,

When I have my game in retina mode and apply an impulse to my box2d bodies, they go twice as fast and twice as far as when in SD mode - is this meant to happen?

Regards,
Steve
I'm not sure exactly how you are doing things, but it sounds like it could be fixed by just halving the impulse when in retina mode.
Hi,

I thought that too, as I guess in retina mode 1 meter is 64 pixels where as in sd mode 1 meter is 32 pixels.

Just thought by doing this it should work, but doesn't:

Code: Select all

_playerBody->ApplyLinearImpulse(b2Vec2(-0.2 / CC_CONTENT_SCALE_FACTOR(),0),_playerBody->GetWorldCenter());


Where when in retina mode CC_CONTENT_SCALE_FACTOR( ) would return 2 and 1 in SD mode.

If I do this in HD mode:

Code: Select all

_playerBody->ApplyLinearImpulse(b2Vec2(0.0f,2.1),_playerBody->GetWorldCenter());

then to get same distance in SD mode I have to do this:

Code: Select all

_playerBody->ApplyLinearImpulse(b2Vec2(0.0f,6.0),_playerBody->GetWorldCenter());


Why 2.1 in HD and 6.0 in SD - doesn't make any sense?

Regards,
Steve
You don't have to worry about HD or SD when using Cocos2d.

Just make sure when you define the size of the body use content size(not content size in pixels) of CCSprite.

Never use CC_CONTENT_SCALE_FACTOR() when applying impulse or force to the b2Body .

Basic idea is to simulate SD world of box2d in HD world.

It worked for me. 😉

Original thread: https://box2d.org/forum/viewtopic.php?t=7612