首页 > 代码库 > kinematic与static刚体不会触发任何接触回调
kinematic与static刚体不会触发任何接触回调
Main.as
package{ import Box2D.Common.Math.b2Vec2; import Box2D.Dynamics.b2Body; import Box2D.Dynamics.Contacts.b2Contact; import Box2D.Collision.b2Manifold; import Box2D.Dynamics.b2ContactImpulse; public class Main extends BaseMain{ public function Main(){ super(new b2Vec2(0,0)); } override protected function init():void{ UIManager.getInstance().init(this); var boxA:b2Body=createBox(30,30,50,300); var circle:b2Body=createCircle(15,50,400); var boxB:b2Body=createBox(50,200,700,300); boxA.SetUserData({type:"boxA"}); circle.SetUserData({type:"circle"}); boxB.SetUserData({type:"boxB"}); boxB.SetType(b2Body.b2_staticBody); boxA.SetType(b2Body.b2_kinematicBody); boxA.SetLinearVelocity(new b2Vec2(10,0)); boxA.SetPreSolveCallback(preSolve); boxA.SetContactBeginCallback(contactBegin); boxA.SetContactEndCallback(contactEnd); boxA.SetPostSolveCallback(postSolve); circle.SetType(b2Body.b2_dynamicBody); circle.SetLinearVelocity(new b2Vec2(5,0)); circle.SetPreSolveCallback(preSolve); circle.SetContactBeginCallback(contactBegin); circle.SetContactEndCallback(contactEnd); circle.SetPostSolveCallback(postSolve); } private function contactBegin(contact:b2Contact,other:b2Body):void{ UIManager.getInstance().print("contactBegin:"+other.GetUserData().type); } private function contactEnd(contact:b2Contact,other:b2Body):void{ UIManager.getInstance().print("contactEnd:"+other.GetUserData().type); } private function postSolve(contact:b2Contact,impulse:b2ContactImpulse,other:b2Body):void{ UIManager.getInstance().print("postSolve:"+other.GetUserData().type); } private function preSolve(contact:b2Contact,oldManifold:b2Manifold,other:b2Body):void{ UIManager.getInstance().print("preSolve:"+other.GetUserData().type); } override protected function stepBefore():void{ } }; }
示例:
源码下载:链接:http://pan.baidu.com/s/1bpL8chh 密码:qui7
kinematic与static刚体不会触发任何接触回调
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。