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


C++ ImageSet::get方法代码示例

本文整理汇总了C++中ImageSet::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageSet::get方法的具体用法?C++ ImageSet::get怎么用?C++ ImageSet::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageSet的用法示例。


在下文中一共展示了ImageSet::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadTargetCursor

void LocalPlayer::loadTargetCursor(const std::string &filename,
                                   const int width, const int height,
                                   const bool outRange,
                                   const TargetCursorSize &size)
{
    assert(size > -1);
    assert(size < 3);

    ResourceManager *resman = ResourceManager::getInstance();

    ImageSet *currentImageSet = resman->getImageSet(filename, width, height);
    Animation *anim = new Animation();

    for (unsigned int i = 0; i < currentImageSet->size(); ++i)
    {
        anim->addFrame(currentImageSet->get(i), 75,
                      (16 - (currentImageSet->getWidth() / 2)),
                      (16 - (currentImageSet->getHeight() / 2)));
    }

    SimpleAnimation *currentCursor = new SimpleAnimation(anim);

    const int index = outRange ? 1 : 0;

    mTargetCursorImages[index][size] = currentImageSet;
    mTargetCursor[index][size] = currentCursor;
}
开发者ID:stevecotton,项目名称:Aethyra,代码行数:27,代码来源:localplayer.cpp

示例2: readEmoteNode

void EmoteDB::readEmoteNode(xmlNodePtr node, const std::string &filename)
{
    int id = XML::getProperty(node, "id", -1);
    if (id == -1)
    {
        logger->log("Emote Database: Emote with missing ID in %s!", filename.c_str());
        return;
    }

    Emote *currentEmote = new Emote;

    currentEmote->name = XML::getProperty(node, "name", "unknown");
    currentEmote->effect = XML::getProperty(node, "effectid", -1);

    if (currentEmote->effect == -1)
    {
        logger->log("Emote Database: Warning: Emote %s has no attached effect in %s!",
                    currentEmote->name.c_str(), filename.c_str());
        delete currentEmote;
        return;
    }

    const std::string imageName = XML::getProperty(node, "image", "");
    const int width = XML::getProperty(node, "width", 0);
    const int height = XML::getProperty(node, "height", 0);

    if (imageName.empty() || width <= 0 || height <= 0)
    {
        logger->log("Emote Database: Warning: Emote %s has bad imageset values in %s",
                    currentEmote->name.c_str(), filename.c_str());
        delete currentEmote;
        return;
    }

    ImageSet *is = ResourceManager::getInstance()->getImageSet(imageName,
                                                               width,
                                                               height);
    if (!is || !(is->size() > 0))
    {
        logger->log("Emote Database: Error loading imageset for emote %s in %s",
                    currentEmote->name.c_str(), filename.c_str());
        delete is;
        delete currentEmote;
        return;
    }
    else
    {
        // For now we just use the first image in the animation
        currentEmote->sprite = new ImageSprite(is->get(0));
    }

    mEmotes[id] = currentEmote;
    if (id > mLastEmote)
        mLastEmote = id;
}
开发者ID:Kenny690,项目名称:mana,代码行数:55,代码来源:emotedb.cpp

示例3: SimpleAnimation

ProgressIndicator::ProgressIndicator()
{
    ImageSet *images = Theme::getImageSetFromTheme("progress-indicator.png",
                       32, 32);

    Animation *anim = new Animation;
    for (ImageSet::size_type i = 0; i < images->size(); ++i)
        anim->addFrame(images->get(i), 100, 0, 0);

    mIndicator = new SimpleAnimation(anim);

    setSize(32, 32);
}
开发者ID:Ablu,项目名称:invertika,代码行数:13,代码来源:progressindicator.cpp

示例4: draw

void Ampermetre::draw(gcn::Graphics *graphics)
{
    mLabel->setCaption(toString(mCurrent));
    mLabel->adjustSize();

    std::stringstream ss;
    ss <<"graphics/elektrik/item-ampermetre.png";
    Graphics *g = static_cast<Graphics*>(graphics);

    ImageSet *res = circuitWindow->mComponentImageSet[ss.str()];
    g->drawImage(res->get(0),4,4);

    Component::draw(graphics);
}
开发者ID:mekolat,项目名称:elektrogamesvn,代码行数:14,代码来源:ampermetre.cpp

示例5: if

ParticleEmitter::ParticleEmitter(const xmlNodePtr &emitterNode, Particle *target,
                                 Map *map, const int rotation):
    mOutputPauseLeft(0),
    mParticleImage(0)
{
    mMap = map;
    mParticleTarget = target;

    // Initializing default values
    mParticlePosX.set(0.0f);
    mParticlePosY.set(0.0f);
    mParticlePosZ.set(0.0f);
    mParticleAngleHorizontal.set(0.0f);
    mParticleAngleVertical.set(0.0f);
    mParticlePower.set(0.0f);
    mParticleGravity.set(0.0f);
    mParticleRandomness.set(0);
    mParticleBounce.set(0.0f);
    mParticleFollow = false;
    mParticleAcceleration.set(0.0f);
    mParticleDieDistance.set(-1.0f);
    mParticleMomentum.set(1.0f);
    mParticleLifetime.set(-1);
    mParticleFadeOut.set(0);
    mParticleFadeIn.set(0);
    mOutput.set(1);
    mOutputPause.set(0);
    mParticleAlpha.set(1.0f);

    for_each_xml_child_node(propertyNode, emitterNode)
    {
        if (xmlStrEqual(propertyNode->name, BAD_CAST "property"))
        {
            std::string name = XML::getProperty(propertyNode, "name", "");

            if (name == "position-x")
                mParticlePosX = readParticleEmitterProp(propertyNode, 0.0f);
            else if (name == "position-y")
            {

                mParticlePosY = readParticleEmitterProp(propertyNode, 0.0f);
                mParticlePosY.minVal *= SIN45;
                mParticlePosY.maxVal *= SIN45;
                mParticlePosY.changeAmplitude *= SIN45;
             }
            else if (name == "position-z")
            {
                mParticlePosZ = readParticleEmitterProp(propertyNode, 0.0f);
                mParticlePosZ.minVal *= SIN45;
                mParticlePosZ.maxVal *= SIN45;
                mParticlePosZ.changeAmplitude *= SIN45;
            }
            else if (name == "image")
            {
                std::string image = XML::getProperty(propertyNode, "value", "");
                // Don't leak when multiple images are defined
                if (!image.empty() && !mParticleImage)
                {
                    ResourceManager *resman = ResourceManager::getInstance();
                    mParticleImage = resman->getImage(image);
                }
            }
            else if (name == "horizontal-angle")
            {
                mParticleAngleHorizontal = readParticleEmitterProp(propertyNode, 0.0f);
                mParticleAngleHorizontal.minVal += rotation;
                mParticleAngleHorizontal.minVal *= DEG_RAD_FACTOR;
                mParticleAngleHorizontal.maxVal += rotation;
                mParticleAngleHorizontal.maxVal *= DEG_RAD_FACTOR;
                mParticleAngleHorizontal.changeAmplitude *= DEG_RAD_FACTOR;
            }
            else if (name == "vertical-angle")
            {
                mParticleAngleVertical = readParticleEmitterProp(propertyNode, 0.0f);
                mParticleAngleVertical.minVal *= DEG_RAD_FACTOR;
                mParticleAngleVertical.maxVal *= DEG_RAD_FACTOR;
                mParticleAngleVertical.changeAmplitude *= DEG_RAD_FACTOR;
            }
            else if (name == "power")
                mParticlePower = readParticleEmitterProp(propertyNode, 0.0f);
            else if (name == "gravity")
                mParticleGravity = readParticleEmitterProp(propertyNode, 0.0f);
            else if (name == "randomnes" || name == "randomness") // legacy bug
                mParticleRandomness = readParticleEmitterProp(propertyNode, 0);
            else if (name == "bounce")
                mParticleBounce = readParticleEmitterProp(propertyNode, 0.0f);
            else if (name == "lifetime")
            {
                mParticleLifetime = readParticleEmitterProp(propertyNode, 0);
                mParticleLifetime.minVal += 1;
            }
            else if (name == "output")
            {
                mOutput = readParticleEmitterProp(propertyNode, 0);
                mOutput.maxVal +=1;
            }
            else if (name == "output-pause")
            {
                mOutputPause = readParticleEmitterProp(propertyNode, 0);
                mOutputPauseLeft = mOutputPause.value(0);
//.........这里部分代码省略.........
开发者ID:Aethyra,项目名称:Client,代码行数:101,代码来源:particleemitter.cpp

示例6: load

void EmoteDB::load()
{
    if (mLoaded)
        unload();

    mUnknown.name = "unknown";
    mUnknown.effect = 0;
    mUnknown.sprite = new ImageSprite(
        ResourceManager::getInstance()->getImage("graphics/sprites/error.png"));

    mLastEmote = 0;

    logger->log("Initializing emote database...");

    XML::Document doc("emotes.xml");
    xmlNodePtr rootNode = doc.rootNode();

    if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "emotes"))
    {
        logger->log("Emote Database: Error while loading emotes.xml!");
        return;
    }

    //iterate <emote>s
    for_each_xml_child_node(emoteNode, rootNode)
    {
        if (!xmlStrEqual(emoteNode->name, BAD_CAST "emote"))
            continue;

        int id = XML::getProperty(emoteNode, "id", -1);
        if (id == -1)
        {
            logger->log("Emote Database: Emote with missing ID in emotes.xml!");
            continue;
        }

        Emote *currentEmote = new Emote;

        currentEmote->name = XML::getProperty(emoteNode, "name", "unknown");
        currentEmote->effect = XML::getProperty(emoteNode, "effectid", -1);

        if (currentEmote->effect == -1)
        {
            logger->log("Emote Database: Warning: Emote with no attached effect!");
            delete currentEmote;
            continue;
        }

        const std::string imageName = XML::getProperty(emoteNode, "image", "");
        const int width = XML::getProperty(emoteNode, "width", 0);
        const int height = XML::getProperty(emoteNode, "height", 0);

        if (imageName.empty() || !(width > 0) || !(height > 0))
        {
            logger->log("Emote Database: Warning: Emote with bad imageset values");
            delete currentEmote;
            continue;
        }

        ImageSet *is = ResourceManager::getInstance()->getImageSet(imageName,
                                                                   width,
                                                                   height);
        if (!is || !(is->size() > 0))
        {
            logger->log("Emote Database: Error loading imageset");
            delete is;
            delete currentEmote;
            continue;
        }
        else
        {
            // For now we just use the first image in the animation
            currentEmote->sprite = new ImageSprite(is->get(0));
        }

        mEmotes[id] = currentEmote;
        if (id > mLastEmote)
            mLastEmote = id;
    }

    mLoaded = true;
}
开发者ID:TonyRice,项目名称:mana,代码行数:82,代码来源:emotedb.cpp

示例7: initializeAnimation

void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode,
                                          const std::string& dyePalettes)
{
    mInitialized = false;

    if (!animationNode)
        return;

    std::string imagePath = XML::getProperty(animationNode,
                                                   "imageset", "");

    // Instanciate the dye coloration.
    if (!imagePath.empty() && !dyePalettes.empty())
        Dye::instantiate(imagePath, dyePalettes);

    ImageSet *imageset = ResourceManager::getInstance()->getImageSet(
        XML::getProperty(animationNode, "imageset", ""),
        XML::getProperty(animationNode, "width", 0),
        XML::getProperty(animationNode, "height", 0)
    );

    if (!imageset)
        return;

    // Get animation frames
    for (xmlNodePtr frameNode = animationNode->xmlChildrenNode; frameNode;
            frameNode = frameNode->next)
    {
        int delay = XML::getProperty(frameNode, "delay", 0);
        int offsetX = XML::getProperty(frameNode, "offsetX", 0);
        int offsetY = XML::getProperty(frameNode, "offsetY", 0);
        Game *game = Game::instance();
        if (game)
        {
            offsetX -= imageset->getWidth() / 2
                - game->getCurrentTileWidth() / 2;
            offsetY -= imageset->getHeight() - game->getCurrentTileHeight();
        }

        if (xmlStrEqual(frameNode->name, BAD_CAST "frame"))
        {
            int index = XML::getProperty(frameNode, "index", -1);

            if (index < 0)
            {
                logger->log("No valid value for 'index'");
                continue;
            }

            Image *img = imageset->get(index);

            if (!img)
            {
                logger->log("No image at index %d", index);
                continue;
            }

            mAnimation->addFrame(img, delay, offsetX, offsetY);
        }
        else if (xmlStrEqual(frameNode->name, BAD_CAST "sequence"))
        {
            int start = XML::getProperty(frameNode, "start", -1);
            int end = XML::getProperty(frameNode, "end", -1);

            if (start < 0 || end < 0)
            {
                logger->log("No valid value for 'start' or 'end'");
                continue;
            }

            while (end >= start)
            {
                Image *img = imageset->get(start);

                if (!img)
                {
                    logger->log("No image at index %d", start);
                    continue;
                }

                mAnimation->addFrame(img, delay, offsetX, offsetY);
                start++;
            }
        }
        else if (xmlStrEqual(frameNode->name, BAD_CAST "end"))
        {
            mAnimation->addTerminator();
        }
    }

    mInitialized = true;
}
开发者ID:Ablu,项目名称:mana,代码行数:92,代码来源:simpleanimation.cpp

示例8: if

SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode):
    mAnimationTime(0),
    mAnimationPhase(0)
{
    mAnimation = new Animation;

    ImageSet *imageset = ResourceManager::getInstance()->getImageSet(
        XML::getProperty(animationNode, "imageset", ""),
        XML::getProperty(animationNode, "width", 0),
        XML::getProperty(animationNode, "height", 0)
    );

    // Get animation frames
    for (   xmlNodePtr frameNode = animationNode->xmlChildrenNode;
            frameNode;
            frameNode = frameNode->next)
    {
        int delay = XML::getProperty(frameNode, "delay", 0);
        int offsetX = XML::getProperty(frameNode, "offsetX", 0);
        int offsetY = XML::getProperty(frameNode, "offsetY", 0);
        offsetY -= imageset->getHeight() - 32;
        offsetX -= imageset->getWidth() / 2 - 16;

        if (xmlStrEqual(frameNode->name, BAD_CAST "frame"))
        {
            int index = XML::getProperty(frameNode, "index", -1);

            if (index < 0)
            {
                logger->log("No valid value for 'index'");
                continue;
            }

            Image *img = imageset->get(index);

            if (!img)
            {
                logger->log("No image at index %d", index);
                continue;
            }

            mAnimation->addFrame(img, delay, offsetX, offsetY);
        }
        else if (xmlStrEqual(frameNode->name, BAD_CAST "sequence"))
        {
            int start = XML::getProperty(frameNode, "start", -1);
            int end = XML::getProperty(frameNode, "end", -1);

            if (start < 0 || end < 0)
            {
                logger->log("No valid value for 'start' or 'end'");
                continue;
            }

            while (end >= start)
            {
                Image *img = imageset->get(start);

                if (!img)
                {
                    logger->log("No image at index %d", start);
                    continue;
                }

                mAnimation->addFrame(img, delay, offsetX, offsetY);
                start++;
            }
        }
        else if (xmlStrEqual(frameNode->name, BAD_CAST "end"))
        {
            mAnimation->addTerminator();
        }
    }

    mCurrentFrame = mAnimation->getFrame(0);
}
开发者ID:kai62656,项目名称:manabot,代码行数:76,代码来源:simpleanimation.cpp


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