本文介绍了cocos2d+box2d游戏中的简单枪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm newbie in box2d. Can you help me?I want to make gun (touch, move, stopped, ball flew).I make detection and rotation of gun, but I can't make popping of ball. How can I count velocity, which I need to set to the ball?Thank you very much
解决方案
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) );
这篇关于cocos2d+box2d游戏中的简单枪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!