cocos2d-x中使用box2d时的PTM
cocos2d-x中使用box2d时的PTM_RATIO定义成多少和box2d本身的特性有关。别人已经解释的很清楚了: http://www.raywenderlich.com/28602/intro-to-box2d-with-cocos2d-2-x-tutorial-bouncing-balls 以下是其中重点部分的摘录: #define PTM_RATIO 32.0 This is
cocos2d-x中使用box2d时的PTM_RATIO定义成多少和box2d本身的特性有关。别人已经解释的很清楚了:
http://www.raywenderlich.com/28602/intro-to-box2d-with-cocos2d-2-x-tutorial-bouncing-balls
以下是其中重点部分的摘录:
#define PTM_RATIO 32.0
|
This is defining a ratio of pixels to “meters”. When you specify where bodies are in Cocos2D, you give it a set of units. Although you may consider using pixels, that would be a mistake. According to the Box2D manual, Box2D has been optimized to deal with units as small as 0.1 and as big as 10. So as far as length goes people generally tend to treat it as “meters” so 0.1 would be about teacup size and 10 would be about box size.
So we don’t want to pass pixels in, because even small objects would be 60×60 pixels, way bigger than the values Box2D has been optimized for. So we need to have a way to convert pixels to “meters”, hence we can just define a ratio like the above. So if we had a 64 pixel object, we could divide it by PTM_RATIO to get 2 “meters” that Box2D can deal with for physics simulation purposes.
上一篇: foobar技巧两则
推荐阅读
-
基于python list对象中嵌套元组使用sort时的排序方法
-
VMware Workstation/Fusion 中安装 Fedora 23/24 及其他 Linux 系统时使用 Open VM Tools 代替 VMware Tools 增强工具的方法
-
解决Android Studio中,使用MediaController时传入参数缺少的问题
-
Winform中在使用VS+svn进行协同开发时添加引用时的相对路径和绝对路径的问题
-
在使用信鸽推送时,自定义接收器发送广播,在自定义application中处理广播时重复处理的
-
使用ajax请求提交数据时,日期类型无法转换为JAVA中的日期类型
-
使用Ant Design中的多选框组件时修改其多选框样式
-
DM数据库表中的CLOB字段,使用ajax查询并显示结果时无法获取该字段值
-
在使用电脑时怎么才能在众多文件中快速找到我想要的文件
-
使用IE浏览器时右下角状态栏中显示"对象不支持此属性或方法"的解决办法