文章分类 -  BOX2D

摘要:因需求要求以下两种效果一)实现箭的飞行效果,要求箭身角度和飞行方向一致(网上很多代码)-(void) update:(ccTime) dt{ //弹道旋转 b2Vec2 vel = buBody->GetLinearVelocity(); //buBody 代表子弹刚体对象 float ang = atanf(vel.y / vel.x); buBody->SetTransform(buBody->GetPosition(),ang); } 二)爆炸效果(炸飞附近body)这个实现也很简单,原理1,遍历b... 阅读全文
posted @ 2012-12-21 09:29 Bmi 阅读(326) 评论(0) 推荐(0)
摘要:【转】http://www.cnblogs.com/sawyerzhu/archive/2012/06/07/2540081.html在很多BOX2D游戏中同样会遇到这样一个问题:如何使一个body自然的按照一个指定速度移动?方法同上次所说的有三种:1-直接设定body的线速度这是最直接的方法,但是同样的,并不是在box2d中最好的方法b2body *body;// the body you want to conrollb2Vec2 vel;// the vel you setbody->SetLinearVelocity( vel );这样做,如果只有一个物体,你可以得到你想要的效果 阅读全文
posted @ 2012-12-04 14:17 Bmi 阅读(261) 评论(0) 推荐(0)