本文整理汇总了C++中CCNode::getRotation方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::getRotation方法的具体用法?C++ CCNode::getRotation怎么用?C++ CCNode::getRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::getRotation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: step
void CCMissile::step(float dt) {
// position of target and aimed
CCNode* target = getTarget();
CCPoint t = target->getPosition();
CCPoint a = m_aimed->getPosition();
// position vector degree
CCPoint v = ccpSub(a, t);
float r = ccpToAngle(v);
float d = -CC_RADIANS_TO_DEGREES(r);
d -= m_presetDegree;
// save dest degree
if(m_dstDegree != d) {
m_dstDegree = d;
}
// rotate to dst degree gradually
if(m_dstDegree > target->getRotation()) {
float cur = MIN(m_dstDegree, target->getRotation() + dt * ANGULAR_VELOCITY);
target->setRotation(cur);
} else if(m_dstDegree < target->getRotation()) {
float cur = MAX(m_dstDegree, target->getRotation() - dt * ANGULAR_VELOCITY);
target->setRotation(cur);
}
// move target by velocity
float move = m_velocity * dt;
float distance = ccpLength(v);
if(move >= distance) {
target->setPosition(a);
} else {
t.x += move * cosf(r);
t.y += move * sinf(r);
target->setPosition(t);
}
// is done?
m_done = getTarget()->getPositionX() == m_aimed->getPositionX() &&
getTarget()->getPositionY() == m_aimed->getPositionY();
// done callback
if(m_done && m_doneCallFunc) {
m_doneCallFunc->execute();
}
}