开发者

what ratio, from pixel to meter will be best and preferable?

I'm using following ratio for pixel to meter conversion,

PTM_RATIO=32;
v3BodyDef.position.Set(2848/PTM_RATIO, 102/PTM_RATIO);

This this produce weird output many times on the screen, s开发者_StackOverflowo does setting position(v3BodyDef.position.Set) take floating point variable or not I don't know, but I think this conversion making trouble.

Please help me with this. Thank you.


There isn't a recommendable ratio for that (though some will try and convince you there is).

The scale of objects in your physics engine should depend on the average scale of your dynamic objects. What I mean is, that if your player interacts with a lot of objects "slightly larger" and "slightly smaller" than itself, it's probably best to make player an average size in the optimal range (for example, Box2D is optimized for objects between 0.1m and 10m in size, so make player 1m, or 1.5m).

As for your pixel size, that all depends on how large you want your world to be on the screen.

If you want your hero to be 1/10th of the screen in height, and 2 meters away from the camera, then do the math :-p Others may want their here to be 1/8th of screen height, or 1/12th.. that really depends on how the game will look in the end. If the camera zooms in, the pixel to physics ratio would change. If the screen resolution changes (like a retina display), your pixel to physics ratio will have to change accordingly.

So in practice: there is no set value. It really depends on the game, and depends on what feels best for the hardware you're on.


It's most likely an integer division problem, change PTM_RATIO to a float (or if you are defining it, use #define PTM_RATIO 16.0f )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜