当前位置: 首页>>代码示例>>C++>>正文


C++ Animation::AddStep方法代码示例

本文整理汇总了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;
}
开发者ID:Panzareon,项目名称:RoguePG,代码行数:22,代码来源:AnimationFactory.cpp

示例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;
    }

}
开发者ID:Panzareon,项目名称:RoguePG,代码行数:83,代码来源:AnimationFactory.cpp


注:本文中的Animation::AddStep方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。