Box2D Forums

It is currently Tue May 21, 2013 6:58 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Sep 14, 2011 4:26 am 
Offline

Joined: Fri Jun 10, 2011 12:48 pm
Posts: 10
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


Top
 Profile  
 
PostPosted: Wed Sep 14, 2011 4:51 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
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.


Top
 Profile  
 
PostPosted: Wed Sep 14, 2011 4:55 am 
Offline

Joined: Fri Jun 10, 2011 12:48 pm
Posts: 10
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:
_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:
_playerBody->ApplyLinearImpulse(b2Vec2(0.0f,2.1),_playerBody->GetWorldCenter());

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

Code:
_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


Top
 Profile  
 
PostPosted: Fri Sep 23, 2011 2:38 am 
Offline

Joined: Sat Mar 05, 2011 5:05 am
Posts: 3
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. ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group