• 帧动画


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

  • 相关阅读:
    EL+Serilog日志
    HttpClientFactory-向外请求的最佳
    Autofac依赖注入
    .Net Core MemoryCache
    时间复杂度和空间复杂度
    中间件-异常处理
    依赖注入-1
    使用并发集合
    安卓刷机&root
    Mac Android Studio 常用快捷键大全
  • 原文地址:https://www.cnblogs.com/cci8go/p/3619019.html
Copyright © 2020-2023  润新知