如何对箭头 Sprite 方向施加力?我需要使用箭头旋转应用。
谢谢。
最佳答案
这是一种实现方式:
cocos2d::Sprite* arrow = ... // defined here
b2Body* body = ... // defined here
// Get the arrow rotation in cocos2d world (deg), and transform it to Box2D world (rad).
float angle = CC_DEGREES_TO_RADIANS(-1 * arrow->getRotation());
// Set the magnitude of the force. It can be any positive number.
float mag = 1;
// Calculate the force vector.
b2Vec2 force(mag * cosf(angle), mag * sinf(angle));
body->ApplyForceToCenter(force, true);
关于c++ - Cocos2d-x box2d applyforce方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35917737/