本文整理汇总了C++中StaticSprite2D::SetEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ StaticSprite2D::SetEnabled方法的具体用法?C++ StaticSprite2D::SetEnabled怎么用?C++ StaticSprite2D::SetEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StaticSprite2D
的用法示例。
在下文中一共展示了StaticSprite2D::SetEnabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsEnabledEffective
void AnimatedSprite2D::OnSetEnabled()
{
StaticSprite2D::OnSetEnabled();
bool enabled = IsEnabledEffective();
Scene* scene = GetScene();
if (scene)
{
if (enabled)
SubscribeToEvent(scene, E_SCENEPOSTUPDATE, HANDLER(AnimatedSprite2D, HandleScenePostUpdate));
else
UnsubscribeFromEvent(scene, E_SCENEPOSTUPDATE);
}
for (unsigned i = 0; i < trackNodes_.Size(); ++i)
{
if (!trackNodes_[i])
continue;
StaticSprite2D* staticSprite = trackNodes_[i]->GetComponent<StaticSprite2D>();
if (staticSprite)
staticSprite->SetEnabled(enabled);
}
}
示例2: SetLoopMode
void AnimatedSprite2D::SetAnimation(Animation2D* animation, LoopMode2D loopMode)
{
if (animation == animation_)
{
SetLoopMode(loopMode_);
currentTime_ = 0.0f;
UpdateAnimation(0.0f);
return;
}
for (unsigned i = 0; i < numTracks_; ++i)
{
if (trackNodes_[i])
trackNodes_[i]->SetEnabled(false);
}
numTracks_ = 0;
trackNodes_.Clear();
trackNodeInfos_.Clear();
animation_ = animation;
if (!animation_)
return;
currentTime_ = 0.0f;
if (!rootNode_)
{
rootNode_ = GetNode()->CreateChild("_root_", LOCAL);
rootNode_->SetTemporary(true);
}
numTracks_ = animation_->GetNumTracks();
trackNodes_.Resize(numTracks_);
trackNodeInfos_.Resize(numTracks_);
for (unsigned i = 0; i < numTracks_; ++i)
{
const AnimationTrack2D& track = animation->GetTrack(i);
SharedPtr<Node> trackNode(rootNode_->GetChild(track.name_));
StaticSprite2D* staticSprite = 0;
if (trackNode)
{
// Enable track node
trackNode->SetEnabled(true);
// Get StaticSprite2D component
if (track.hasSprite_)
staticSprite = trackNode->GetComponent<StaticSprite2D>();
}
else
{
// Create new track node
trackNode = rootNode_->CreateChild(track.name_, LOCAL);
trackNode->SetTemporary(true);
// Create StaticSprite2D component
if (track.hasSprite_)
{
staticSprite = trackNode->CreateComponent<StaticSprite2D>();
staticSprite->SetEnabled(IsEnabledEffective());
}
}
if (staticSprite)
{
staticSprite->SetLayer(layer_);
staticSprite->SetBlendMode(blendMode_);
staticSprite->SetFlip(flipX_, flipY_);
staticSprite->SetUseHotSpot(true);
}
trackNodes_[i] = trackNode;
trackNodeInfos_[i].hasSprite = track.hasSprite_;
}
SetLoopMode(loopMode);
UpdateAnimation(0.0f);
MarkNetworkUpdate();
}