本文整理汇总了C++中Sprite3D::getSkeleton方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite3D::getSkeleton方法的具体用法?C++ Sprite3D::getSkeleton怎么用?C++ Sprite3D::getSkeleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite3D
的用法示例。
在下文中一共展示了Sprite3D::getSkeleton方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CCASSERT
//! called before the action start. It will also set the target.
void Animate3D::startWithTarget(Node *target)
{
Sprite3D* sprite = dynamic_cast<Sprite3D*>(target);
CCASSERT(sprite && sprite->getSkeleton() && _animation, "Animate3D apply to Sprite3D only");
ActionInterval::startWithTarget(target);
_boneCurves.clear();
auto skin = sprite->getSkeleton();
bool hasCurve = false;
for (int i = 0; i < skin->getBoneCount(); i++) {
auto bone = skin->getBoneByIndex(static_cast<unsigned int>(i));
auto curve = _animation->getBoneCurveByName(bone->getName());
if (curve)
{
_boneCurves[bone] = curve;
hasCurve = true;
}
}
if (!hasCurve)
{
CCLOG("warning: no animation finde for the skeleton");
}
auto runningAction = s_runningAnimates.find(sprite);
if (runningAction != s_runningAnimates.end())
{
//make the running action fade out
auto action = (*runningAction).second;
if (action != this)
{
if (_transTime < 0.001f)
{
s_runningAnimates[sprite] = this;
_state = Animate3D::Animate3DState::Running;
_weight = 1.0f;
}
else
{
s_fadeOutAnimates[sprite] = action;
action->_state = Animate3D::Animate3DState::FadeOut;
action->_accTransTime = 0.0f;
action->_weight = 1.0f;
action->_lastTime = 0.f;
s_fadeInAnimates[sprite] = this;
_accTransTime = 0.0f;
_state = Animate3D::Animate3DState::FadeIn;
_weight = 0.f;
_lastTime = 0.f;
}
}
}
else
{
s_runningAnimates[sprite] = this;
_state = Animate3D::Animate3DState::Running;
_weight = 1.0f;
}
}
示例2: findChildByNameRecursively
//! called before the action start. It will also set the target.
void Animate3D::startWithTarget(Node *target)
{
bool needReMap = (_target != target);
ActionInterval::startWithTarget(target);
if (needReMap)
{
_boneCurves.clear();
_nodeCurves.clear();
bool hasCurve = false;
Sprite3D* sprite = dynamic_cast<Sprite3D*>(target);
if(sprite)
{
if (_animation)
{
const std::unordered_map<std::string, Animation3D::Curve*>& boneCurves = _animation->getBoneCurves();
for (const auto& iter: boneCurves)
{
const std::string& boneName = iter.first;
auto skin = sprite->getSkeleton();
if(skin)
{
auto bone = skin->getBoneByName(boneName);
if (bone)
{
auto curve = _animation->getBoneCurveByName(boneName);
_boneCurves[bone] = curve;
hasCurve = true;
}
else
{
Node* node = nullptr;
if (target->getName() == boneName)
node = target;
else
node = findChildByNameRecursively(target, boneName);
if (node)
{
auto curve = _animation->getBoneCurveByName(boneName);
if (curve)
{
_nodeCurves[node] = curve;
hasCurve = true;
}
}
}
}
}
}
}
else
{
const std::unordered_map<std::string, Animation3D::Curve*>& boneCurves = _animation->getBoneCurves();
for (const auto& iter: boneCurves)
{
const std::string& boneName = iter.first;
Node* node = nullptr;
if (target->getName() == boneName)
node = target;
else
node = findChildByNameRecursively(target, boneName);
if (node)
{
auto curve = _animation->getBoneCurveByName(boneName);
if (curve)
{
_nodeCurves[node] = curve;
hasCurve = true;
}
}
}
}
if (!hasCurve)
{
CCLOG("warning: no animation found for the skeleton");
}
}
auto runningAction = s_runningAnimates.find(target);
if (runningAction != s_runningAnimates.end())
{
//make the running action fade out
auto action = (*runningAction).second;
if (action != this)
{
if (_transTime < 0.001f)
{
s_runningAnimates[target] = this;
_state = Animate3D::Animate3DState::Running;
_weight = 1.0f;
}
else
{
//.........这里部分代码省略.........