创建 和使用 CCAnimation
来源:互联网 发布:汇编和c语言的区别 编辑:程序博客网 时间:2024/05/21 06:51
1- 直接加载图片文件作为frame
CCAnimation *robotAnim = [CCAnimation animation]; // 4[robotAnim addFrameWithFilename:@"an1_anim2.png"]; // 5[robotAnim addFrameWithFilename:@"an1_anim3.png"];[robotAnim addFrameWithFilename:@"an1_anim4.png"];id robotAnimationAction = [CCAnimate actionWithDuration:0.5f animation:robotAnim restoreOriginalFrame:YES]; // 6
2- 通过预加载FrameCache文件作为frame,frameName的图片必须已经加载到FrameCache中。
// Animation example with a CCSpriteBatchNodeCCAnimation *exampleAnim = [CCAnimation animation];[exampleAnim addFrame: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"sv_anim_2.png"]];[exampleAnim addFrame: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"sv_anim_3.png"]];[exampleAnim addFrame: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"sv_anim_4.png"]];id animateAction = [CCAnimate actionWithDuration:0.5f animation:exampleAnim restoreOriginalFrame:NO];id repeatAction = [CCRepeatForever actionWithAction:animateAction];
PS. 可以把Animation加入到AnimationCache
[[CCAnimationCache sharedAnimationCache] addAnimation:animationToCache name:@"AnimationName"];在需要时取出
CCAnimation *myAnimation = [[CCAnimationCache sharedAnimationCache] animationByName:@"AnimationName"];
这样就不用总持有animation。
- 创建 和使用 CCAnimation
- Cocos2d-X使用CCAnimation创建动画
- Cocos2d-X使用CCAnimation创建动画
- CCAnimation创建动画
- CCSpriteFrame 、CCAnimation 的使用
- CCAnimation 和 CCAnimate 区别
- CCAnimate和CCAnimation区别
- CCAnimation创建动画cocos2d-x
- CCAnimation创建动画 cocos2d-x
- CCAnimation创建动画cocos2d-x教程
- CCAnimation创建动画(cocos2d-x)
- 笨小五工作笔录之-动画创建CCAnimation
- Cocos2d-x使用CCAnimation小实验——显示植物大战僵尸中的植物和僵尸
- 【cocos2dx之CCAnimation、CCAnimate、CCAnimationCache使用】
- CCAnimation创建动画-沈大海cocos2d-x教程22
- 从CCAnimation获取第一帧来创建CCSprite实例
- CCAnimation之 不指定帧数来创建动画
- 使用CCAnimate、CCAnimation、CCTextureCache、CCTexture2D来实现动画效果
- C#的对象相等比较问题
- 自平衡二叉查找树(一)-----------AVL树分析和代码实现
- redo
- 聚集索引和非聚集索引的区别
- 各种学习资源
- 创建 和使用 CCAnimation
- 如何禁止IIS缓存静态文件(png,js,html等)
- Flash在线文档开发思路
- 人生最痛苦的事是在一个问题上面出现两次错误
- 在Linux下编译Google leveldb数据库及在C++中操作示例
- c++ 元组使用
- 注册表
- 【win32调用html】HtmlCtrl屏蔽右键方法总结
- 常用纽扣型号对照表