TexturePacker的使用
点击Add Sprites按钮添加动画帧
点击publish生成plist文件与打包图片
把生成的plist文件与png文件添加到工程的资源文件目录
帧动画效果的实现
-
-
-
- CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("skill/skill26.plist","skill/skill26.png");
- CCArray* frames = CCArray::createWithCapacity(18);
- CCSpriteFrame* frame;
- for (int i=1; i<=18; ++i)
- {
- if(i<10){
-
- frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::createWithFormat("skill26-0%d.png",i)->getCString());
- }
- else{
- frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::createWithFormat("skill26-%d.png",i)->getCString());
- }
- frames->addObject(frame);
- }
-
-
- CCAnimation* pAnimSkill44 = CCAnimation::createWithSpriteFrames(frames,0.2f);
-
-
- CCAnimate* pSkill44 = CCAnimate::create(pAnimSkill44);
-
-
- CCSprite* pSprite = CCSprite::create();
- pSprite->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
- this->addChild(pSprite,1);
- pSprite->runAction(CCRepeatForever::create(pSkill44));