Esempio n. 1
0
cocos2d::Vec2 GameEntity::getForwardVector() const {

	cocos2d::Vec2 forwardVector;
	const cocos2d::Vec2 initialForward = cocos2d::Vec2(0.0f, 1.0f);

	float rotationRadians = CC_DEGREES_TO_RADIANS(getRotation());
	const cocos2d::Node* parent = getParent();

	while (parent) {

		rotationRadians += CC_DEGREES_TO_RADIANS(parent->getRotation());
		parent = parent->getParent();
	}

	forwardVector = initialForward.rotateByAngle(cocos2d::Vec2::ZERO, rotationRadians);
	forwardVector.x *= -1.0f;

	return forwardVector;
}