物体旋转

void HomeWork::speedMove(float dt)
{
	degress += 5;
	float nexPosX	=	cos(CC_RADIANS_TO_DEGREES(degress)) * dist; 
	float nexPosY	=	sin(CC_RADIANS_TO_DEGREES(degress)) * dist;

	enemy->setPosition( Point(nexPosX,nexPosY) + targetPoint);

	float dx		=	enemy->getPositionX() - targetPoint.x;
	float dy		=	enemy->getPositionY() - targetPoint.y;
	float radian	=	atan2(dy,dx);
	float deg		=	CC_RADIANS_TO_DEGREES(radian);
	
	enemy->setRotation(-deg + 90);

}

你可能感兴趣的:(物体旋转)