您的位置:首页 > 移动开发 > Cocos引擎

Box2d学习笔记六:b2Body所用的属性和物理属性

2014-03-09 21:39 323 查看
今天我们学习了b2Body的属性和物理属性。刚体的属性封装在一个叫b2BodyDef的类中,注意,在box2d中凡是以def结尾的类都是某某属性的封装类。打开API文档:

b2BodyDef:

b2BodyType type
//刚体的类型,动态、静态
b2Vec2 position
float32 angle
//角度
 The world angle of the body in radians. 
b2Vec2 linearVelocity
//线性速度
 The linear velocity of the body's origin in world co-ordinates. 
float32 angularVelocity
//角速度
 The angular velocity of the body. 
float32 linearDamping
//线性阻尼
float32 angularDamping
//角度阻尼
bool allowSleep
//是否能睡眠
bool awake
//是否在唤醒状态
 Is this body initially awake or sleeping? 
bool fixedRotation
//固定旋转,就不能自转了
 Should this body be prevented from rotating? Useful for characters. 
bool bullet
//刚体是否为子弹类型,当两个速度很快的刚体发生碰撞的时候,会出现穿透现象,如果设置该属性就可以保证正确的发生碰撞
bool active
//是否激活状态,注意与sleep分开,sleep是照样发生物理模拟,而如果active为false,则刚体不参与任何物理模拟
 Does this body start out active? 
void * userData
//用户数据
 Use this to store application specific body data. 
float32 gravityScale
//几倍重力
 Scale the gravity applied to this body. 
大家有木有发觉这些属性和物理沾不上边呢?是的,这些并不是刚体的物理属性。如果看过前几篇就知道,物理属性是通过框架附加的,ok

b2FixtureDef

const b2Shape * shape
//框架的形状
void * userData
 Use this to store application specific fixture data. 
float32 friction
//摩擦系数
 The friction coefficient, usually in the range [0,1]. 
float32 restitution
//恢复系数
 The restitution (elasticity) usually in the range [0,1]. 
float32 density
//密度
 The density, usually in kg/m^2. 
bool isSensor
//是否是感应器
b2Filter filter
//筛选器
 Contact filtering data. 
有了上面这些属性,就可以完美的模拟刚体的物理运动了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐