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


C++ AnimationFrame类代码示例

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


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

示例1:

void YHCCActionHelper::runIntervalForeverAnimation2(float interval, cocos2d::CCAnimation * animation,
                                                    cocos2d::CCSprite * pSprite,
                                                    const std::function<void ()> & begin_callback,
                                                    const std::function<void ()> & end_callback)
{
    Vector<FiniteTimeAction *> actions;
    Animate * animate = Animate::create(animation);
    Hide * hide = Hide::create();
    DelayTime * delay = DelayTime::create(interval);
    Show * show = Show::create();
    
    if (begin_callback != nullptr)
    {
        CallFunc * callfunc = CallFunc::create(begin_callback);
        actions.pushBack(callfunc);
    }
    actions.pushBack(animate);
    actions.pushBack(hide);
    actions.pushBack(delay);
    actions.pushBack(show);
    if (end_callback != nullptr)
    {
        CallFunc * callfunc = CallFunc::create(end_callback);
        actions.pushBack(callfunc);
    }
    
    Sequence * sequence = Sequence::create(actions);
    RepeatForever * repeatForever = RepeatForever::create(sequence);
    AnimationFrame * frame = animate->getAnimation()->getFrames().at(0);
    pSprite->setDisplayFrame(frame->getSpriteFrame());
    pSprite->runAction(repeatForever);
}
开发者ID:bontey,项目名称:cocos2d-x-tools,代码行数:32,代码来源:YHCCActionHelper.cpp

示例2: CCASSERT

bool Animate::initWithAnimation(Animation *pAnimation)
{
    CCASSERT( pAnimation!=NULL, "Animate: argument Animation must be non-NULL");

    float singleDuration = pAnimation->getDuration();

    if ( ActionInterval::initWithDuration(singleDuration * pAnimation->getLoops() ) ) 
    {
        _nextFrame = 0;
        setAnimation(pAnimation);
        _origFrame = NULL;
        _executedLoops = 0;

        _splitTimes->reserve(pAnimation->getFrames()->count());

        float accumUnitsOfTime = 0;
        float newUnitOfTimeValue = singleDuration / pAnimation->getTotalDelayUnits();

        Array* pFrames = pAnimation->getFrames();
        CCARRAY_VERIFY_TYPE(pFrames, AnimationFrame*);

        Object* pObj = NULL;
        CCARRAY_FOREACH(pFrames, pObj)
        {
            AnimationFrame* frame = static_cast<AnimationFrame*>(pObj);
            float value = (accumUnitsOfTime * newUnitOfTimeValue) / singleDuration;
            accumUnitsOfTime += frame->getDelayUnits();
            _splitTimes->push_back(value);
        }    
开发者ID:Gamex,项目名称:GameX,代码行数:29,代码来源:CCActionInterval.cpp

示例3: draw

void Animation::draw(ResourceLoader *resLoader, SDL_Surface *screen, AnimationInstance *ai, float x, float y)
{
	AnimationFrame *currFrame = NULL;
	float cumulativeTime = 0;
	float timeThisFrame = 0;
	float timeInSeconds = ai->getComplete()*totalTime;
	for (int i = 0; i < numFrames; ++i)
	{
		if (timeInSeconds >= cumulativeTime)
		{
			timeThisFrame = timeInSeconds-cumulativeTime;
			currFrame = &(frames[i]);
		}else
		{
			break;
		}
		cumulativeTime += currFrame->getTime();
	}
	if (currFrame != NULL)
	{
		for (int i = 0; i < currFrame->getEffectSize(); ++i)
			currFrame->getEffect(i)->setTime(timeThisFrame);
		for (int i = 0; i < currFrame->getNumImages(); ++i)
		{
			Pos2 *offset = currFrame->getOffset(i);
			resLoader->draw_image(
				currFrame->getImage(i), 
				screen, x+offset->getX(), 
				y+offset->getY(), currFrame->getEffects(), currFrame->getEffectSize());
		}
	}
	//SDL_BlitSurface( resLoader->get_image(currFrame->image_type), src_rect, screen, dst_rect );
}
开发者ID:happypandaface,项目名称:sdl_wii,代码行数:33,代码来源:animation.cpp

示例4: W_UNUSED

    void AnimationAffector::end(long long dt, long long age) {
        W_UNUSED(dt); W_UNUSED(age);

        if(priv->restoreOriginal) {
            sprite->texture(priv->originalTexture);
            sprite->frame(priv->originalFrame.x(), priv->originalFrame.y());
        } else {
            AnimationFrame f = priv->animation->last();
            sprite->texture(f.texture());
            sprite->frame(f.frame().x(), f.frame().y());
        }
    }
开发者ID:winglot,项目名称:WEngine,代码行数:12,代码来源:W_AnimationAffector.cpp

示例5: duplicate

    /// Duplicate from given frame.
    ///
    /// \param op Frame to duplicate.
    void duplicate(const AnimationFrame &op)
    {
      unsigned bone_count = op.getBoneCount();

      m_time = op.getTime();
      m_bones.resize(bone_count);

      for(unsigned ii = 0; (bone_count > ii); ++ii)
      {
        m_bones[ii] = op.getBoneState(ii);
      }
    }
开发者ID:faemiyah,项目名称:faemiyah-demoscene_2016-08_80k-intro_my_mistress_the_leviathan,代码行数:15,代码来源:verbatim_animation_frame.hpp

示例6: CCDICT_FOREACH

void AnimationCache::parseVersion1(Dictionary* animations)
{
    SpriteFrameCache *frameCache = SpriteFrameCache::sharedSpriteFrameCache();

    DictElement* pElement = NULL;
    CCDICT_FOREACH(animations, pElement)
    {
        Dictionary* animationDict = (Dictionary*)pElement->getObject();
        Array* frameNames = (Array*)animationDict->objectForKey("frames");
        float delay = animationDict->valueForKey("delay")->floatValue();
        Animation* animation = NULL;

        if ( frameNames == NULL ) 
        {
            CCLOG("cocos2d: AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", pElement->getStrKey());
            continue;
        }

        Array* frames = Array::createWithCapacity(frameNames->count());
        frames->retain();

        Object* pObj = NULL;
        CCARRAY_FOREACH(frameNames, pObj)
        {
            const char* frameName = ((String*)pObj)->getCString();
            SpriteFrame* spriteFrame = frameCache->spriteFrameByName(frameName);

            if ( ! spriteFrame ) {
                CCLOG("cocos2d: AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the SpriteFrameCache. This frame will not be added to the animation.", pElement->getStrKey(), frameName);

                continue;
            }

            AnimationFrame* animFrame = new AnimationFrame();
            animFrame->initWithSpriteFrame(spriteFrame, 1, NULL);
            frames->addObject(animFrame);
            animFrame->release();
        }

        if ( frames->count() == 0 ) {
            CCLOG("cocos2d: AnimationCache: None of the frames for animation '%s' were found in the SpriteFrameCache. Animation is not being added to the Animation Cache.", pElement->getStrKey());
            continue;
        } else if ( frames->count() != frameNames->count() ) {
            CCLOG("cocos2d: AnimationCache: An animation in your dictionary refers to a frame which is not in the SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", pElement->getStrKey());
        }

        animation = Animation::create(frames, delay, 1);

        AnimationCache::sharedAnimationCache()->addAnimation(animation, pElement->getStrKey());
        frames->release();
    }    
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:51,代码来源:CCAnimationCache.cpp

示例7: CCASSERT

void Sprite::setDisplayFrameWithAnimationName(const std::string& animationName, ssize_t frameIndex)
{
    CCASSERT(animationName.size()>0, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be nullptr");

    Animation *a = AnimationCache::getInstance()->getAnimation(animationName);

    CCASSERT(a, "CCSprite#setDisplayFrameWithAnimationName: Frame not found");

    AnimationFrame* frame = a->getFrames().at(frameIndex);

    CCASSERT(frame, "CCSprite#setDisplayFrame. Invalid frame");

    setSpriteFrame(frame->getSpriteFrame());
}
开发者ID:AIRIA,项目名称:CreazyBomber,代码行数:14,代码来源:CCSprite.cpp

示例8: _initPlayer

    void MovieSprite::initPlayer()
    {
        if (_initialized)
            return;

        _initialized = true;

        _initPlayer();

        Point sz = _bufferSize;
        //sz = Point(nextPOT(sz.x), nextPOT(sz.y));

        Point uvSize = _bufferSize / 2;
        //uvSize = Point(nextPOT(uvSize.x), nextPOT(uvSize.y));
        //uvSize = sz;

        _mtUV.init(uvSize.x, uvSize.y, TF_A8L8);
        _mtUV.fill_zero();
        _textureUV = IVideoDriver::instance->createTexture();
        _textureUV->init(uvSize.x, uvSize.y, _mtUV.getFormat(), false);

        _mtYA.init(sz.x, sz.y, _hasAlphaChannel ? TF_A8L8 : TF_L8);
        _mtYA.fill_zero();
        _textureYA = IVideoDriver::instance->createTexture();
        _textureYA->init(sz.x, sz.y, _mtYA.getFormat(), false);

        if (_hasAlphaChannel)
            setBlendMode(blend_premultiplied_alpha);
        else
            setBlendMode(blend_disabled);

        Diffuse d;
        d.base = _textureYA;
        d.alpha = _textureUV;
        d.premultiplied = true;

        AnimationFrame frame;
        RectF mr = _movieRect.cast<RectF>();

        Vector2 szf = sz.cast<Vector2>();
        RectF tcYA = RectF(mr.pos.div(szf), mr.size.div(szf));
        frame.init(0, d, tcYA, mr, mr.size);

        _yaScale = Vector2(uvSize.x / szf.x, uvSize.y / szf.y);
        _yaScale = Vector2(0.5f, 0.5f);
        _yaScale = Vector2(1, 1);
        Vector2 s = getSize();
        setAnimFrame(frame);
        setSize(s);
    }
开发者ID:oxygine,项目名称:oxygine-movie,代码行数:50,代码来源:MovieSprite.cpp

示例9: TextureLine

        TextureLine(spNativeTexture t)
        {
            setVerticalMode(Box9Sprite::TILING_FULL);
            setHorizontalMode(Box9Sprite::TILING_FULL);
            Sprite::setResAnim(DebugActor::resSystem->getResAnim("checker"));

            AnimationFrame f;
            Vector2 s = fitSize(itemSize, Vector2((float)t->getWidth(), (float)t->getHeight()));

            setSize(s);

            Diffuse df;
            df.base = t;

            f.init(0, df, RectF(0, 0, 1.0f, 1.0f), RectF(0, 0, s.x, s.y), s);
            spSprite image = initActor(new Sprite,
                                       arg_blend = blend_disabled,
                                       arg_resAnim = f);
            addChild(image);

            spColorRectSprite rect = initActor(new ColorRectSprite,
                                               arg_color = Color(Color::White, 255),
                                               arg_attachTo = this);

            rect->addTween(Sprite::TweenColor(Color(Color::White, 0)), 4000, -1, true);

            char path[255];
            path::normalize(t->getName().c_str(), path);

            char txt[255];
            safe_sprintf(txt, "%s\n<div c=\"FF0000\">%s</div>-<div c=\"0000ff\">%dx%d</div>\nid: %d",
                         path,
                         textureFormat2String(t->getFormat()),
                         t->getWidth(), t->getHeight(), t->getObjectID());

            spTextField text = initActor(new TextField,
                                         arg_color = Color::Black,
                                         arg_w = (float)itemSize.x,
                                         arg_vAlign = TextStyle::VALIGN_TOP,
                                         arg_hAlign = TextStyle::HALIGN_LEFT,
                                         arg_multiline = true,
                                         arg_attachTo = rect,
                                         arg_htmlText = txt
                                        );

            text->setBreakLongWords(true);

            rect->setSize(text->getTextRect().size.cast<Vector2>() + Vector2(2, 2));
            rect->setY((itemSize.y - rect->getHeight()) / 2.0f);
        }
开发者ID:ivlevAstef,项目名称:PrototypeCarGame,代码行数:50,代码来源:TexturesInspector.cpp

示例10: setAnimFrame

	void Sprite::setResAnim(const ResAnim *resanim)
	{
		if (resanim)
		{
			if (resanim->getTotalFrames()) 
				setAnimFrame(resanim);
			else
			{
				AnimationFrame fr;

				fr.init(0, Diffuse(), RectF(0,0,0,0), RectF(0,0,0,0), getSize());
				setAnimFrame(fr);
			}
		}
		else
			setAnimFrame(AnimationFrame());
	}
开发者ID:raymondlu,项目名称:oxygine-framework,代码行数:17,代码来源:Sprite.cpp

示例11: changeAnimFrame

    void Sprite::setAnimFrame(const ResAnim* resanim, int col, int row)
    {
        //OX_ASSERT(resanim);
        if (!resanim)
        {
            changeAnimFrame(AnimationFrame());
            return;
        }

        if (resanim->getTotalFrames())
        {
            const AnimationFrame& frame = resanim->getFrame(col, row);
            changeAnimFrame(frame);
        }
        else
        {
            AnimationFrame frame;
            frame.setSize(getSize());
            changeAnimFrame(frame);
        }
    }
开发者ID:pixelpicosean,项目名称:lesser-panda-oxygine,代码行数:21,代码来源:Sprite.cpp

示例12: interpolateFrom

    /// Interpolate animation frame from two other frames.
    ///
    /// \param src Source frame (earlier).
    /// \param dst Destination frame (later).
    /// \param current_time Animation time.
    void interpolateFrom(const AnimationFrame &lhs, const AnimationFrame &rhs, float current_time)
    {
      unsigned bone_count = lhs.getBoneCount();
#if defined(USE_LD)
      if(rhs.getBoneCount() != bone_count)
      {
        std::ostringstream sstr;
        sstr << "cannot interpolate between frames of size " << bone_count << " and " << rhs.getBoneCount();
        BOOST_THROW_EXCEPTION(std::runtime_error(sstr.str()));
      }
#endif

      //std::cout << "resizing bones or not? " << m_bones.size() << " vs " << bone_count << std::endl;

      m_time = current_time;
      m_bones.resize(bone_count);

      for(unsigned ii = 0; (bone_count > ii); ++ii)
      {
        const BoneState &ll = lhs.getBoneState(ii);
        const BoneState &rr = rhs.getBoneState(ii);
        float ltime = lhs.getTime();
        float rtime = rhs.getTime();
        float mix_time = (current_time - ltime) / (rtime - ltime);
        vec3 mix_pos = mix(ll.getPosition(), rr.getPosition(), mix_time);
        quat mix_rot = mix(ll.getRotation(), rr.getRotation(), mix_time);

        //std::cout << "mix time: " << mix_time << ": " << mix_pos << " ; " << mix_rot << std::endl;

        m_bones[ii] = BoneState(mix_pos, mix_rot);
      }
    }
开发者ID:faemiyah,项目名称:faemiyah-demoscene_2016-08_80k-intro_my_mistress_the_leviathan,代码行数:37,代码来源:verbatim_animation_frame.hpp

示例13: r

    void TreeInspectorPreview::init(spActor item)
    {
        //_item = item;
        STDRenderer r(&_videoCache);
        RenderState rs;
        rs.renderer = &r;
        rs.transform = item->getTransform();
        r.begin(0);
        //r.setTransform(rs.transform);
        item->doRender(rs);
        r.end();
        r.drawBatch();

        setSize(30, 30);

        RectF itemRect = _videoCache._bounds;
        if (itemRect.isEmpty())
        {
            itemRect = item->getDestRect();
            if (itemRect.isEmpty())
                itemRect.setSize(Vector2(10, 4));
        }

        Vector2 ns = fitSize(Vector2(50.0f, 50.0f), itemRect.size);
        float scale = ns.x / itemRect.size.x;

        _cacheTransform.identity();

        _cacheTransform.scale(Vector2(scale, scale));
        _cacheTransform.translate(-itemRect.pos);



        AnimationFrame fr = _tree->_resSystem->getResAnim("checker")->getFrame(0, 0);
        //Point itemSize(30, 30);// = _getItemRect().size;

        RectF srcRect = fr.getSrcRect();
        const Diffuse& df = fr.getDiffuse();
        srcRect.size.x = ns.x / (float)df.base->getWidth();
        srcRect.size.y = ns.y / (float)df.base->getHeight();
        RectF destRect = fr.getDestRect();
        destRect.size = ns;

        AnimationFrame cfr;
        cfr.init(0, df, srcRect, destRect, ns);

        setAnimFrame(cfr);


        /*
        spEventHandler bh = new EventHandler();

        bh->setCallbackEnter(CLOSURE(this, &TreeInspectorPreview::_onEvent));
        bh->setCallbackExit(CLOSURE(this, &TreeInspectorPreview::_onEvent));
        bh->setCallbackPressDown(CLOSURE(this, &TreeInspectorPreview::_onEvent));
        bh->setCallbackPressUp(CLOSURE(this, &TreeInspectorPreview::_onEvent));
        addEventHandler(bh);
        */
    }
开发者ID:poplax,项目名称:oxygine-framework,代码行数:59,代码来源:TreeInspectorPreview.cpp

示例14: frameSize

    void ResAnim::init(spNativeTexture texture, const Point& originalSize, int columns, int rows, float scaleFactor)
    {
        _scaleFactor = scaleFactor;
        if (!texture)
            return;

        int frame_width = originalSize.x / columns;
        int frame_height = originalSize.y / rows;

        animationFrames frames;
        int frames_count = rows * columns;
        frames.reserve(frames_count);

        Vector2 frameSize((float)frame_width, (float)frame_height);
        for (int y = 0; y < rows; ++y)
        {
            for (int x = 0; x < columns; ++x)
            {
                Rect src;
                src.pos = Point(x * frame_width, y * frame_height);
                src.size = Point(frame_width, frame_height);

                float iw = 1.0f / texture->getWidth();
                float ih = 1.0f / texture->getHeight();
                RectF srcRect(src.pos.x * iw, src.pos.y * ih, src.size.x * iw, src.size.y * ih);

                RectF destRect(Vector2(0, 0), frameSize * scaleFactor);
                AnimationFrame frame;
                Diffuse df;
                df.base = texture;
                frame.init(this, df, srcRect, destRect, destRect.size);
                frames.push_back(frame);
            }
        }

        init(frames, columns, scaleFactor);
    }
开发者ID:Jesus05,项目名称:oxygine-framework,代码行数:37,代码来源:ResAnim.cpp

示例15: frame

void AnimationFrameView::setOnionSkinFrames()
{

    if(onionSkinBackward() > 0 && onionSkinForward()) {
        QList<AnimationFrame *> onionSkinFrames;
        int index = frame()->project()->frames().indexOf(frame());
        int beginOfOnionSkin = max(0, index-onionSkinBackward());
        int endOfOnionSkin = min(frame()->project()->frameCount(), index+onionSkinForward());
        if(endOfOnionSkin == frame()->project()->frameCount())
            endOfOnionSkin--;

        for(int i = beginOfOnionSkin; i < index; i++) {
            onionSkinFrames.push_back(frame()->project()->frame(i));
        }
        for(int i= index+1; i<= endOfOnionSkin; i++) {
            onionSkinFrames.push_back(frame()->project()->frame(i));
        }
        if(onionSkinFrames.size() > 0) {
            onionSkin = new QPixmap(frameItem->scene()->width(), frameItem->scene()->height());
            onionSkin->fill(Qt::transparent);
            QPainter *p = new QPainter(onionSkin);

            p->setOpacity(0.5);
            for (int i = 0; i < onionSkinFrames.size(); ++i) {
                AnimationFrame *f = onionSkinFrames.at(i);
                for (int j = f->layerCount() - 1; j >= 0; --j) {
                    const Layer *layer = f->layer(j);
                    const Canvas& canvas = (layer->canvas().pixmap());
                    p->drawPixmap(0, 0, canvas.pixmap());
                }
            }

            repaint();
        }
    }
}
开发者ID:mkacz91,项目名称:apricot,代码行数:36,代码来源:animationframeview.cpp


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