[笔记]Cocoa训练营-cocos2d游戏编程篇-动画
来源:互联网 发布:js 数组由小到大排序 编辑:程序博客网 时间:2024/06/03 07:42
cocos2d 1.0及其以上版本
游戏动画随笔;
1 -(id)init 2 { 3 self=[super init]; 4 if (self) { 5 CCSprite *sp=[CCSprite spriteWithFile:@"Space.png"]; 6 sp.anchorPoint=CGPointZero; 7 sp.opacity=100; 8 [self addChild:sp z:0 tag:1]; 9 //分数10 CCLabelBMFont *lbScore=[CCLabelBMFont labelWithString:@"Time : 0" fntFile:@"font09.fnt"];11 lbScore.anchorPoint=ccp(1, 1);12 lbScore.scale=0.6;13 lbScore.position=ccp(310, 450);14 [self addChild:lbScore z:1 tag:3];15 //载入图像集16 CCSpriteBatchNode *mgr=[CCSpriteBatchNode batchNodeWithFile:@"flight.png" capacity:5];17 [self addChild:mgr z:0 tag:4];18 CCSprite *spriter=[CCSprite spriteWithTexture:mgr.texture rect:CGRectMake(0, 0, 31, 30)];19 [mgr addChild:spriter z:1 tag:5];20 spriter.scale=1.1;21 spriter.anchorPoint=ccp(0, 1);22 spriter.position=ccp(10, 410);23 24 25 CCLabelBMFont *lbLife=[CCLabelBMFont labelWithString:@"3" fntFile:@"font09.fnt"];26 lbLife.anchorPoint=ccp(0.0, 0.l);27 lbLife.scale=0.6;28 [self addChild:lbLife z:1 tag:6];29 lbLife.position=ccp(50, 400);30 //单一的飞机 取31,30 坐标之图片31 flight=[CCSprite spriteWithTexture:mgr.texture rect:CGRectMake(0, 0, 31, 30)];32 flight.anchorPoint=ccp(0, 1);33 flight.scale=1.6;34 flight.position=ccp(160, 40);35 [self addChild:flight z:1 tag:99];36 /动画部分代码**************************************************
*************************************************************/
37 CCSpriteFrame *frame=[CCSpriteFrame frameWithTexture:mgr.texture rect:CGRectMake(0, 0,31,30)];38 NSArray *array=[[NSArray alloc]initWithObjects:frame, nil];39 //动画40 CCAnimation *animation2=[CCAnimation animationWithSpriteFrames:array delay:0.2f];41 //动画42 for (int i=0; i!=3; i++) {43 int x=i%3;44 [animation2 addSpriteFrameWithTexture:mgr.texture rect:CGRectMake(x*32, 0, 31, 30)];45 }46 //动作47 id action=[CCAnimate actionWithAnimation:animation2];48 //循环49 [flight runAction:[CCRepeatForever actionWithAction:action]];50 /*****************************************************************/51 // self.isTouchEnabled=YES;52 53 }54 return self;55 }
- [笔记]Cocoa训练营-cocos2d游戏编程篇-动画
- 【Cocos2d-x游戏引擎开发笔记(4)】系统动画
- 【Cocos2d-x游戏引擎开发笔记(5)】自定义动画
- 【Cocos2d-html5游戏引擎学习笔记(10)】自定义精灵动画
- 【Cocos2d-x游戏引擎开发笔记(4)】系统动画
- 【Cocos2d-x游戏引擎开发笔记(5)】自定义动画
- Cocos2d-x手机游戏开发C编程基础---笔记一
- 游戏编程入门学习笔记15——添加动画
- 黑马训练营-学习笔记----网络编程
- 黑马训练营-------------网络编程学习笔记
- 【Cocos2d-x游戏引擎开发笔记(16)】动画速度的控制
- 【Cocos2d-x游戏引擎开发笔记(16)】动画速度的控制
- Cocoa多线程编程笔记:NSLock与NSThread
- cocos2d-x学习笔记-动画
- cocos2d-x游戏开发(十六)帧动画
- cocos2d-x游戏开发(十六)帧动画
- Cocoa学习笔记 Cocos2d 各种动作介绍 (上)
- Cocoa学习笔记 Cocos2d 各种动作介绍 (下)
- python学习八:网络编程初探
- Android 3D滑动菜单完全解析,实现推拉门式的立体特效
- 静态变量和实例变量的区别
- 暑假月结
- AngularJs+bootstrap搭载前台框架——js控制部分
- [笔记]Cocoa训练营-cocos2d游戏编程篇-动画
- [原创]Xcode 4.6 安装 Boost 1.53.0
- 《UNIX环境高级编程》笔记--UNIX标准化及实现
- 多标签分类(multilabel classification )
- E2
- dazhilu飞鸽传书 2013 官方网站
- 某保密单位机要人员 A,B,C,D,E 每周需要工作5天,休息2天。 上级要求每个人每周的工作日和休息日安排必须是固定的,不能在周间变更。 此外,由于工作需要,还有如下要求:
- Linux延时函数
- 环境:GLScene 安装