本文整理汇总了C++中Animation::AddStep方法的典型用法代码示例。如果您正苦于以下问题:C++ Animation::AddStep方法的具体用法?C++ Animation::AddStep怎么用?C++ Animation::AddStep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Animation
的用法示例。
在下文中一共展示了Animation::AddStep方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTextAnimation
Animation* AnimationFactory::GetTextAnimation(Entity* target, std::string text, sf::Color color, float xTranslate, float yTranslate )
{
if(target->GetNode() == nullptr)
{
//If there is no Node, animation can not be displayed
return nullptr;
}
sf::FloatRect startPos = target->GetNode()->getGlobalBoundingBox();
sf::Transform startTransform;
startTransform.translate(startPos.left + xTranslate, startPos.top + yTranslate);
Animation* ret;
ret = new Animation(0.2f);
AnimationPartText* part = new AnimationPartText(text, color, 12);
sf::FloatRect bounds = part->GetText()->getLocalBounds();
startTransform.translate((startPos.width - bounds.width) / 2, - bounds.height / 2);
part->SetTiming(0.0f, 0.2f);
part->SetStartTransform(startTransform);
part->SetTranslation(-3.0f, - 10.0f);
part->SetScaling(1.5f);
ret->AddStep(part);
return ret;
}
示例2: GetAnimation
Animation* AnimationFactory::GetAnimation(AnimationList anim, sf::FloatRect startPos)
{
//play the animation at a given Position
sf::Transform startTransform;
startTransform.translate(startPos.left, startPos.top);
Animation* ret;
switch(anim)
{
case Fireball:
{
ret = new Animation(0.2f);
AnimationPartSprite* part = new AnimationPartSprite(TextureList::FireballAnimation);
sf::FloatRect spriteBounds = part->GetSprite()->getLocalBounds();
startTransform.translate((startPos.width - spriteBounds.width) / 2, (startPos.height - spriteBounds.height) / 2);
part->SetTiming(0.0f, 0.2f);
part->SetStartTransform(startTransform);
part->SetScaling(3.0f);
ret->AddStep(part);
SoundController::GetInstance()->PlaySound(SoundController::Fire);
return ret;
}
break;
case Water:
{
float yMovement = 50.0f;
ret = new Animation(0.2f);
AnimationPartSprite* part = new AnimationPartSprite(TextureList::WaterAnimation);
sf::FloatRect spriteBounds = part->GetSprite()->getLocalBounds();
startTransform.translate((startPos.width - spriteBounds.width) / 2, (startPos.height - spriteBounds.height) / 2 - yMovement);
part->SetTiming(0.0f, 0.2f);
part->SetStartTransform(startTransform);
part->SetTranslation(0.0f, yMovement);
ret->AddStep(part);
SoundController::GetInstance()->PlaySound(SoundController::Water);
return ret;
}
case Earth:
{
float yMovement = 75.0f;
ret = new Animation(0.2f);
AnimationPartSprite* part = new AnimationPartSprite(TextureList::EarthAnimation);
sf::FloatRect spriteBounds = part->GetSprite()->getLocalBounds();
startTransform.translate((startPos.width - spriteBounds.width) / 2, (startPos.height - spriteBounds.height) / 2 - yMovement);
part->SetTiming(0.0f, 0.2f);
part->SetStartTransform(startTransform);
part->SetTranslation(0.0f, yMovement);
ret->AddStep(part);
SoundController::GetInstance()->PlaySound(SoundController::Earth);
return ret;
}
case Air:
{
float xMovement = -30.0f;
ret = new Animation(0.2f);
AnimationPartSprite* part = new AnimationPartSprite(TextureList::AirAnimation);
sf::FloatRect spriteBounds = part->GetSprite()->getLocalBounds();
startTransform.translate((startPos.width - spriteBounds.width) / 2 - xMovement, (startPos.height - spriteBounds.height) / 2);
part->SetTiming(0.0f, 0.2f);
part->SetStartTransform(startTransform);
part->SetTranslation(xMovement, 0.0f);
ret->AddStep(part);
SoundController::GetInstance()->PlaySound(SoundController::Wind);
return ret;
}
case Sword:
{
float yMovement = 75.0f;
ret = new Animation(0.2f);
AnimationPartSprite* part = new AnimationPartSprite(TextureList::SwordAnimation);
sf::FloatRect spriteBounds = part->GetSprite()->getLocalBounds();
startTransform.translate((startPos.width - spriteBounds.width) / 2, (startPos.height - spriteBounds.height) / 2 - yMovement);
part->SetTiming(0.0f, 0.2f);
part->SetStartTransform(startTransform);
part->SetTranslation(0.0f, yMovement);
ret->AddStep(part);
SoundController::GetInstance()->PlaySound(SoundController::Hit);
return ret;
}
default:
return nullptr;
}
}