TuftEntertainment / hashtag-warrior

Open-source iOS game powered by cocos2d.
MIT License
8 stars 7 forks source link

Mass is messed up. #24

Open verbitan opened 11 years ago

verbitan commented 11 years ago

Open the game on the iPhone then the iPad, you'll notice that they don't behave in the same way.

I believe that this is because the iPad uses higher resolution images, therefore they're larger and Box2D thinks that they've got more mass.

danielgwood commented 11 years ago

Been looking into this one a bit by examining just the Projectile objects.

As we set the same density (1.0) for all devices, the dodgy mass must indeed be based on the size of the objects. We attempt to set the size directly from the content (i.e. the sprites themselves), then this is adjusted by the PTM_RATIO. However, the sizes aren't what I expected:

iPhone Actual texture diameter: 32px Reported by CCSprite.contentSize.width: 32px Metres (once adjusted by PTM_RATIO): 0.5

iPhone HD Actual texture diameter: 64px Reported by CCSprite.contentSize.width: 32px Metres (once adjusted by PTM_RATIO): 0.5

iPad Actual texture diameter: 128px Reported by CCSprite.contentSize.width: 128px Metres (once adjusted by PTM_RATIO): 2.0

iPad HD Actual texture diameter: 256px Reported by CCSprite.contentSize.width: 128px Metres (once adjusted by PTM_RATIO): 2.0

verbitan commented 11 years ago

Wouldn't this fix it?

define PTM_RATIO (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 64 : 32)

verbitan commented 11 years ago

I think what is also making this worse is that our ratio between devices is wrong. So even if we get the PTM_RATIO setup correctly it'll still feel wrong as the two are not directly comparable.

iPhone Reported by CCSprite.contentSize.width: 32px Reported by [[CCDirector sharedDirector] winSize].width: 480px Ratio between these: 480/32 = 15

iPad Reported by CCSprite.contentSize.width: 128px Reported by [[CCDirector sharedDirector] winSize].width: 1024px Ratio between these: 1024/128 = 8