摘要: //[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];[[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:selfpriority:0swallowsTouches:YES]; 阅读全文
posted @ 2013-01-14 15:52 diablo大王 阅读(532) 评论(0) 推荐(0) 编辑
摘要: 通常调用某个动作的方法://创建动作 idactionTo=[CCMoveToactionWithDuration:2position:ccp(s.width-40,s.height-40)]; //使用动作。(说明:tamara是一个CCSprite。) [tamararunAction:actionTo];瞬时动作顾名思义。瞬时动作就是不需要时间,马上就完成的动作。瞬时动作的共同基类是 InstantAction。放置 – Place效果类似于 node.Position = ccp(x, y)。之所以作为一个动作来实现是为了可以与其他动作形成一个连续动作。示例:(void)OnPlace 阅读全文
posted @ 2013-01-14 15:46 diablo大王 阅读(190) 评论(0) 推荐(0) 编辑
摘要: GL坐标系 Cocos2D以OpenglES为图形库,所以它使用OpenglES坐标系。GL坐标系原点在屏幕左下角,x轴向右,y轴向上。 屏幕坐标系 苹果的Quarze2D使用的是不同的坐标系统,原点在屏幕左上角,x轴向右,y轴向下。ios的屏幕触摸事件CCTouch传入的位置信息使用的是该坐标系。因此在cocos2d中对触摸事件做出响应前需要首先把触摸点转化到GL坐标系。可以使用CCDirector的convertToGL来完成这一转化。 世界坐标系 世界坐标系也叫做绝对坐标系,是游戏开发中的概念,它建立了描述其他坐标系所需要的参考框架。我们能够用世界坐标系来描述其他坐标系的位置,... 阅读全文
posted @ 2013-01-14 10:21 diablo大王 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 1. UITouch 的主要方法:C代码-(void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event;-(void)touchesMoved:(NSSet*)toucheswithEvent:(UIEvent*)event;-(void)touchesEnded:(NSSet*)toucheswithEvent:(UIEvent*)event;-(void)touchesCancelled:(NSSet*)toucheswithEvent:(UIEvent*)event;-(void)motionBegan:(UIEventSubty 阅读全文
posted @ 2013-01-14 10:19 diablo大王 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 1. 说下iphone游戏的启动流程答:(1) 主程序入口 – main.mInt main(int argc, char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; UIApplicationMain(argc, argv, nil, @”T01AppDelegate”); [pool drain]; return 0;}(2) 讲程序的控制权传递给了应用程序代理对象 – 代码中是: T01AppDelegate类T01AppDelegate 对象通过实现iphone OS 系统定义的应用程序接 阅读全文
posted @ 2013-01-13 10:17 diablo大王 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 当你用CCDirector replaceScene方法替换场景时, 每个节点都会调用CCNode所带的三个方法。这三个方法是:onEnter, onEnterTransitionDidFinish和onExit。取决于是否使用了CCTransitionScene, onEnter和onExit会在场景转换过程中的某个时间点被调用。对于这三个方法, 你必须调用它们的super方法以避免触摸输入问题和内存泄漏的问题。-(void) onEnter{ // 节点调用init方法以后将会调用此方法 // 如果使用了CCTransitionScene,将会在过渡效果开始以后调用此方法 [supe... 阅读全文
posted @ 2013-01-11 16:25 diablo大王 阅读(489) 评论(0) 推荐(0) 编辑
摘要: #import <Foundation/Foundation.h>#import "cocos2d.h"@interface GameScene : CCLayer{ CCSprite* player;}+(id) scene;@end启用加速计输入,创建并定位玩家精灵 -(id) init { if ((self = [super init])) { self.isAccelerometerEnabled = YES; // 支持重力加速 player = [CCSprite spriteWithFile:@"alien.pn... 阅读全文
posted @ 2013-01-09 13:48 diablo大王 阅读(346) 评论(0) 推荐(0) 编辑
摘要: 1、cocos2d很好的利用了单例设计模式以下是一些最常用到的cocos2d 单例类和访问它们的方法: CCActionManager* sharedManager = [CCActionManager sharedManager]; CCDirector* sharedDirector = [CCDirector sharedDirector]; CCSpriteFrameCache* sharedCache = [CCSpriteFrameCache sharedSpriteFrameCache]; CCTextureCache* sharedTexCache = [CCTextureCa 阅读全文
posted @ 2013-01-08 11:19 diablo大王 阅读(381) 评论(0) 推荐(0) 编辑
摘要: 1、如果你拥有(通过 alloc、copy 或 retain 得到)一个对象,就必须在用完之后释放它。 24 2、如果你已经向一个对象发送了自动释放消息,就不该再释放它。 阅读全文
posted @ 2013-01-08 10:54 diablo大王 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 1、“HelloWorld_prefix.pch”头文件的作用是给编译过程加速。你应该把不常变化的框架(Frameworks)头文件添加到前缀头文件(prefix header)中。这样 的话,在编译的时候,框架的代码会被预先编译,所有的类都将可以使用这些 头文件。不幸的是,这样做也有一个缺点:如果前缀头文件里其中一个头文件 发生了变化,你的所有代码将会重新编译。这就是为什么你应该只添加那些极 少或者从来都不变化的头文件到前缀头文件中。#ifdef __OBJC__ #import <Foundation/Foundation.h> #import <UIKit/UIKi.. 阅读全文
posted @ 2013-01-08 09:18 diablo大王 阅读(299) 评论(0) 推荐(0) 编辑