大佬教程收集整理的这篇文章主要介绍了Cocos2d-x入门: 序列帧动画实现,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
cocos2d-x 2.x
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("<span style="font-family: Arial,Helvetica,sans-serif;">Splash</span><span style="font-family: Arial,sans-serif;">.plist");</span> CCArray* splashFrames = CCArray::create(); for (int i=1; i<=23; i++) { const char* str = CCString::createWithFormat("Splash_%04d.png",i)->getCString(); CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(str); splashFrames->addObject(framE); } CCAnimation *splashAnim = CCAnimation::create(); splashAnim = CCAnimation::createWithSpriteFrames(splashFrames,0.02f); CCAnimation *splashAnim = CCAnimation::createWithSpriteFrames(splashFrames,0.2); splashAnim->setLoops(1); CCAnimate *animate = CCAnimate::create(splashAnim); CCSprite* animSprite = CCSprite::createWithSpriteFramename("<span style="font-family: Arial,sans-serif;">Splash_</span><span style="font-family: Arial,sans-serif;">0000.png");</span> animSprite->runAction(animatE); 或者: CCAnimationCache* animationCache = CCAnimationCache::sharedAnimationCache(); animationCache->addAnimationsWithFile("dealer_smile_ani.plist"); CCAnimation* animation = animationCache->animationByName("dealer_smile_ani"); nimSprite->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCAnimate::create(animation),CCDelayTime::create(2.5f))));
Cocos2d-x 3.x
Vector<SpriteFrame*> splashFrames; for (int i=1; i<=23; i++) { const char* str = CCString::createWithFormat("Splash_%04d.png",i)->getCString(); SpriteFrame* frame = cache->getSpriteFrameByName(str); splashFrames.pushBACk(framE); } Animation *splashAnim = Animation::create(); splashAnim = Animation::createWithSpriteFrames(splashFrames,0.02f);
很明显,2.x与3.x的实现方式,最大的区别在于3.x用不定长的Vector来组织帧序列,相对更加灵活.
2.x的两种方式更加plist的不同类型区分:frame和animal类型。
以上是大佬教程为你收集整理的Cocos2d-x入门: 序列帧动画实现全部内容,希望文章能够帮你解决Cocos2d-x入门: 序列帧动画实现所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。