zoukankan      html  css  js  c++  java
  • 帧动画

    1.动画的调用

    CCAnimation *pAnimation = CPalaceControl::Instance()->InitSimpleAnimation(ANIMATION_TRIBUTE_POSTION, 8, PalaceConfig::ANIMATION_TIME_PER_FRAME, true);
    if (NULL == pAnimation)
    {
    return false;
    }

    pSpQuan->runAction(CCRepeatForever::actionWithAction(CCAnimate::actionWithAnimation(pAnimation)));

    const string CLiFoLogic::ANIMATION_TRIBUTE_POSTION = "FoPosition";  (单个图片名字FoPosition1.png)

    static const float ANIMATION_TIME_PER_FRAME= 0.0667f;

    2.动画的实现

    CCAnimation * CPalaceControl::InitSimpleAnimation(
    const string &strFileName, const int &nFramesCount, const float &fTimePerFrame, const bool &bReadWriteble)
    {
    CCSpriteFrameCache *pCache = CCSpriteFrameCache::sharedSpriteFrameCache();
    if (NULL == pCache)
    {
    return NULL;
    }

    pCache->addSpriteFramesWithFile(
    FileUtil::SelectFilePath(CommonUtil::CreatePlistFileName(strFileName), bReadWriteble).c_str(),
    FileUtil::SelectFilePath(CommonUtil::CreateImageFileName(strFileName), bReadWriteble).c_str());

    CCMutableArray<CCSpriteFrame *> *pAnimFrames = new CCMutableArray<CCSpriteFrame*>(nFramesCount);
    char str[100] = {0};
    for(int i = 1; i <= nFramesCount; i++)
    {
    sprintf(str, (strFileName + "%d.png").c_str(), i);
    CCSpriteFrame *pFrame = pCache->spriteFrameByName(str);
    pAnimFrames->addObject(pFrame);
    }

    CCAnimation *pAnimation = CCAnimation::animationWithFrames(pAnimFrames, fTimePerFrame);
    pAnimFrames->removeAllObjects(true);
    CC_SAFE_DELETE(pAnimFrames)

    return pAnimation;
    }

  • 相关阅读:
    VS2015编译OpenSSL1.0.2源码
    VS2015编译CURL7.54.0源码
    Mac OS Yosemite 文件批量重命名
    https 原理
    把本地仓库导入到Github
    jquery cdn加速注意事项
    关于CSS 里的_width是什么意思???
    HTML的footer置于页面最底部的方法
    html-include
    GitHub Permission to <<repository>> denied to <<username>>
  • 原文地址:https://www.cnblogs.com/cci8go/p/3619019.html
Copyright © 2011-2022 走看看