• 帧动画


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

  • 相关阅读:
    下载MATLAB硬件支持包的方法
    chromium 编译源码里面的单一模块 测试用例
    cc/animation
    raster 像素化
    Property Trees & DispalyItem
    Charles的HTTPS抓包
    git 修改.gitignore后未生效
    Word2Vec原理详解
    Pytorch中的Embedding
    在mac m1上安装tensorflow报错“zsh: illegal hardware instruction”
  • 原文地址:https://www.cnblogs.com/cci8go/p/3619019.html
Copyright © 2020-2023  润新知