- 浏览: 261938 次
- 性别:
- 来自: 济南
文章分类
最新评论
-
hyxj1220:
原来是这么回事,,谢谢了
document的execCommand解释 -
zouhongmin:
太强了,我膜拜你,要向你学习。
减肥日志 -
codeboy_wang:
超炫 超喜欢
document的execCommand解释 -
laiang8283:
博主男的女的,100斤也不是很胖啊
减肥日志 -
yixiaof:
博主真有毅力啊。
减肥日志
http://bsr1983.iteye.com/blog/1628520
http://blog.csdn.net/kobbbb/article/details/7750458
http://blog.csdn.net/kmyhy/article/details/6583782
山东省青岛市市南区香港中路30号世奥国际6楼文明盛世
工具下载:
http://www.codeandweb.com/texturepacker
只使用一个层来接受事件和处理事件,这个层通过转发事件来通知其他节点或类。
高手博客
http://developer.apple.com/library/ios/navigation/
http://www.cnblogs.com/andyque/articles/1997820.html
http://www.cnblogs.com/andyque/archive/2011/06/09/2074962.html
http://www.otierney.net/objective-c.html#downloading
http://www.ityran.com/portal.php
http://www.cnblogs.com/andyque/archive/2011/06/09/2074962.html
http://www.raywenderlich.com/tutorials
http://t.dianping.com/deal/38751
http://www.xuanyusong.com/archives/950
http://www.xuanyusong.com/archives/1370
http://www.raywenderlich.com/tutorials
http://blog.csdn.net/xhfjiao/article/details/6858270#
高手QQ 4006333186
源码下载
http://www.learn-cocos2d.com/store/book-learn-cocos2d/
http://cocos2d-central.com/topic/29-games-made-with-the-books-source-code/
Cocos2d最基本的类是CCNode,拥有坐标,这个是所有类的父类,
CCSence--场景, 是抽象的的容器,只是包容其他
使用方法:
CCScene * scene = [CCScene node];
[scene addChild:[GameLayer node];
[[CCDirector sharedDirector]replaceScene:[CCTransitionSplitRowstransitionWithDuration:1.2f scene:scene]];
切换场景的2种方式
1)直接替换场景
[[CCDirtory sharedDirectory]replaceScene:[GameLayer scene]];
2)从init 函数开始执行
CCScene * scene = [CCScene node];
[scene addChild:[GameLayer node]];树下
[[CCDirector sharedDirector]replaceScene:[CCTranssitionSplitRows transitionWithDuration:1.2f scene:secne]];//缩放的形式切换场景的方法
CCLayer--
1)CCocos2d推荐对象生成是
其中CCNode 的node生成源码是
+(id)node
{
return [[[self alloc]init]autorelease];
}
2)
如果需要响应的控件需要添加tag
label.tag = 13
3)CCLayer响应触摸事件
步骤1:
self.isTouchEnabled = true;
步骤2:
在CCLayer响应消息
-(void)ccTouchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
CCNode * node = [self getChildByTag:13];
CCLabelTTF * label = (CCLabelTTF*) node;
label.scale = CCRANDOM_0_1();
}
4)CCNode
4.1)CCNode的子类:CCAtlasNode,CCLayer,CCMenuItem,CCMotionStreak,CCParallaxNode,CCParticleSystem,CCProgeressTimer,CCScene,CCSprite,CCSpriteBatchNode,
4.2) node可以添加,删除,通过tag访问
4.3)node可以有各种动作action,
action的声明
CCAction * action = [CCBlink actionWithDuration:10 blinkk:20];
action.tag =13;
action的运行,停止;
[node runAction:action]; [node stopAction:action]; [node stopAllActions];
4.4)node可以响应各种消息,例如update(刷新消息);
步骤一:-(void) scheduleUpdateMethod
{
[self scheduleUpdate];
}
步骤二:响应消息
-(void)update:(ccTime)delta
{
}
5)CCDiretory 全局对象,配置信息,场景管理(替换,push,pop),决定游戏如何更新状态,UIKit2D和OpenGL3D坐标转换。
[[CCDirector sharedDirector]runWithScene:[HelloWorld scene]];
[[CCDirector sharedDirector]replaceScene:[HelloWorld scene]];
[[CCDirector sharedDirector]pushScene:[Setting scene]];
[[CCDirector sharedDirector]popScene];
效果替换
CCTransitionFade * tran = [CCTransitionFade transitionWithFuration:1 scene:[HelloWorld scene] withColor:ccWHITE];
[[CCDirector sharedDirector]replaceScene:tran];
6)CCScene 是个抽象类,只是用来做容器,一般就是用来包含CCLayer对象
游戏一开始肯定有个场景,这个场景的生成,而且这个场景有一个层HelloWorld
+(id)scene
{
CCScene * scene = [CCScene node];
CCLayer * layer = [HelloWorld node];
[scene addChild:layer];
return scene;
}
7)CCLayer
在场景创建的时候添加几个层。注意不要设计太多层,尤其是用户交互的层最好是一个层,
+(id)scene
{
CCScene * scene = [CCScene node];
CCLayer * backgroundLayer = [HelloWorldBackground node];
[scene addChild: backgroundlayer];
CCLayer * layer = [HelloWorld node];
[scene addChild:layer];
CCLayer * userInterfaceLayer = [HelloWorldUserInterface node];
[scene addChild:userInterfaceLayer];
return scene;
}
touch事件:
步骤一:
self.isTouchEnabled = YES;
步骤二:
-(void)ccTouchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
例子: 坐标转换(OpenGL坐标):
-(CGPoint)locationFromTouches:(NSSet *)touches
{
UITouch * touch = [touches anyObject];
CGPoint touchLocation = [touch loactionInView:[touch view]];
return [[CCDirectory sharedDirector]convertToGL:touchLocation];
}
CCLayer可以接受touch输入,和Accelerometer(加速器)事件
步骤一:self.isAccelerometerEnabled = YES;
步骤二:响应事件
-(void) accelerometer:(UIAcceleromter *)acceleromter
didAccelerate:(UIAcceleration*)acceleration
{
CGLOG(@"acceleration: x:%f/ y:%f /z:%f",acceleration.x,acceleration.y,acceleration.z);
}
CCLayer接受键盘事件
步骤一:self.isKeyBoardEnabled = YES;
步骤二:-(BOOL) ccKeyDown:(NSEvent*)event
{
CCLOG(@"key pressed:%@",[event charaactrers]);
}
CCLayer接受鼠标事件
步骤一:self.isMouseEnabled = YES;
步骤二:响应鼠标事件
-(BOOL)ccMouseDragged:(NSEvent*)event{}
-(BOOL)ccScrollWheel:(NSEvent*)event{}
注意鼠标事件中也需要进行坐标转换
CGPoint mousePos = [[CCDirector sharedDirector]convertEventToGL:event];
8)CCSprite-- 生成方式一:已经添加到工程中的图片文件
CCSprite * sprite = [CCSprite spriteWithFile:@"Default.png"];
[self addChild:sprite];
9)CCLableTTF
CCLabelTTF *label = [CCLabelTTF labelWithString:@"text"
fontName:@"AppleGothic"
fontSize:32];
[self addChild:label];
[label setString:@"new text"];
10)Menus
11)全局唯一对象
CCActionManager * sharedManager = [CCActionManager sharedManager];
CCDirector * sharedDirector = [CCDirector sharedDirector];
CCSpriteFrameCache * sharedCache = [CCSpriteFrameCache sharedSpriteFrameCache];
CCTextureCache * sharedTexCache = [CCTextureCache sharedTextureCache];
CCTouchDispatcher* sharedDispatcher = [CCTouchDispatcher sharedDispatcher];
2012-6-29
游戏level的实现有2种思路一种是用不同Scene实现,一种是用CCLayer实现。
2012-7-2
如何创建并且运行sprite动画步骤
1.创建NSMutableArray;NSMutableArray* frames = [NSMutableArray arrayWithCapacity:5];
2.遍历每一个动画帧:
a每个图片创建一个CCTexture2D纹理
CCTexture2D* texture = [[CCTextureCache sharedTextureCache] addImage:file];;
b用CCTexture纹理创建一个CCSpriteFrame帧,
CCSpriteFrame* frame = [CCSpriteFrame frameWithTexture:texture rect:texRect];
c把每一个CCSpriteFrame添加到NSMutableArray.
[frames addObject:frame];
3.利用NSMutableArray来创建 CCAnimation* anim = [CCAnimation animationWithFrames:frames delay:0.08f];
2012-7-5
安装cocos2d sudo ./install-templates.sh
2012-7-30
通过大图片加载生成 CCSpriteBatchNode 是为了一次绘画多个图片。
而加载加载.plist文件,它里面包含了这张大图里面的所有的小图的位置坐标信息。这样,你以后可以非常方便地使用 spriteWithSpriteFrameName来提取一张张小图片来初使化一些精灵。
想要在cocos2d里面使用视差滚动效果非常简单。你只需要做3步就ok了:
- 创建一个CCParallaxNode,然后把它加到层中去。
- 创建你想要滚动的元素,然后通过调用CCParallaxNode的 addChild:parallaxRatio:positionOffset方法把这些元素添加进去。
- 移动CCParallaxNode来滚动背景。这样的话,CCParallaxNode就会根据parallaxRatio的不同,或快或慢地移动它里面添加的元素了。
- TakeAWalk.zip (947.3 KB)
- 下载次数: 3
- 新建文件夹.rar (1.6 KB)
- 下载次数: 1
- FruitLink.zip (777.7 KB)
- 下载次数: 1
- SpaceGame.zip (1.5 MB)
- 下载次数: 3
发表评论
-
2013学习
2013-02-18 17:23 8692013-2-18 http://developer.a ... -
xcode下控制台中文乱码
2013-01-08 12:20 2985http://blog.csdn.net/ydj213/art ... -
cocos2d game +ios5 之蜘蛛
2012-10-12 11:04 1092http://tobia.github.com/CrossSl ... -
Box2d基本知识
2012-08-31 17:39 592http://www.ohcoder.com/post/201 ... -
转objective-c 中随机数的用法 (3种:arc4random() 、random()、CCRANDOM_0_1() )
2012-08-08 11:22 809http://map.baidu.com/?qt=inf&am ... -
cocos2d游戏开发思路
2012-06-29 16:44 02012-6-29 游戏level的实现有2种思路一种 ... -
下载列表
2012-06-20 09:53 595写进去心里的那些话----- 当被别人忽略、冷落的时 ... -
[转载]转载 【IOS】Object-C 中的Selector 概念 (2012-01-10 16:37:55)
2012-06-19 16:01 696原文地址:转载 【IOS】Object-C 中的Sel ... -
object-C
2012-06-19 16:40 11571.@class用在循环嵌入#impo ... -
xcode4.3秘笈
2012-05-22 11:35 5191.It's just slightly different ... -
ios面试题收集
2012-04-09 14:43 2407objective-c学习网页 ht ... -
CCScene,CCLayer,CCSprite,CCNode
2012-04-05 16:22 807http://blog.csdn.net/porsch ... -
objective-c多参数解析和@class声明的作用
2012-03-30 09:37 2275Objective-C 多参数成员函数 ... -
cocos2d做游戏之一入门
2012-03-28 10:37 1406有的时候发现做一件事 ... -
xcode4.2下创建MainWindow
2012-03-28 09:41 9281、创建Empty Application工程;注意创建时的C ... -
iphone下的导航视图
2012-03-19 16:05 1325UINavigationController的特点 ... -
iphone下的多视图 --xcode3.1实现
2012-03-16 11:27 1745苹果电脑os是Mac os 而ipon ... -
一个view两个tableview
2012-03-14 09:59 6593http://www.trappers.tk/site/201 ... -
xcode4.2里自定义viewController和view切换
2012-03-03 22:59 26101)添加自定义 viewController 在新版的v ... -
iphone中的触摸手势判断,滑动,单击,双击
2012-03-06 09:48 2935/////////////////////////////// ...
相关推荐
NULL 博文链接:https://icrwen.iteye.com/blog/1696902
非常好的ios游戏开发电子书,使用cocos2d引擎
cocos2d 粒子特效 ios game
Learn cocos2d 2 Game Development for iOS pdf document
Master game development with Cocos2d to develop amazing mobile games for iOS About This Book Learn how to create beautiful and engaging mobile games using Cocos2D-Swift Explore the cross-platform ...
Did you ever imagine yourself writing a computer game and being able to make money selling it?... And you’ve chosen one of the most interesting game engines to work with: cocos2d for iOS.
Learn cocos2d Game Development with iOS5 - (Steffen Itterheim & Andreas Low 著) 英文高清原版 (非扫描版)
cocos2d naturato mouse game ios
iOS Game Programming with Xcode and Cocos2d(完整版) 自己收集的
Create compelling 2D games with Learn cocos2d 2: Game Development with iOS. This book shows you how to use the powerful new cocos2d, version 2 game engine to develop games for iPhone and iPad with ...
Cocos2d-x is an amazing open source game engine that allows developers to exploit their existing C++, Lua, and JavaScript knowledge for cross-platform deployment into iOS, Android, Windows Phone, ...
naruto ios game cocos2d
cocos2d ios box2d game
苹果IOS平台游戏设计教程Learn iPhone and iPad Cocos2D Game Development
Learn.cocos2d.Game.Development.with.iOS.5 包括有cocos2d的框架介绍,主要是讲在ios5上利用cocos2d开发游戏,英文版