首页 > 其他 > 详细

帧动画

时间:2014-03-23 16:56:22      阅读:384      评论:0      收藏:0      [点我收藏+]

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

帧动画,布布扣,bubuko.com

帧动画

原文:http://www.cnblogs.com/cci8go/p/3619019.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!