Simple gun in cocos2d+box2d game

a 夏天 提交于 2019-11-27 09:10:44

The easiest way is to look at the direction the gun is pointing when you define the body, and use GetWorldVector to see how it has changed. For example if the gun is pointing directly upwards when you create the body, this would be the direction (0,1). Then you can use GetWorldVector at any time to get the current direction of that vector in world coordinates:

body->GetWorldVector( b2Vec2(0,1) );
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!