`
rayln
  • 浏览: 415641 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
文章列表
在调用ccbi文件后很多时候需要做一次元素渲染完成后的回调函数。 看例子: CCScene *scene = [CCBReader sceneWithNodeGraphFromFile:@"StartMain.ccbi" ]; [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:scene withColor:ccWHITE]]; 该scene中所有元素渲染完成后需要一个回调函数 比如Scene的类是MainScene - ...
1。 由于retina和普通屏像素相差2倍,所以需要一套高清图片 修改非常简单, 例如: 普通图片 image.png 高清图片名 image@2x.png 这样,系统就会自动识别和匹配图片! 2。如果App运行中从网络异步获取图片进行显示,或游戏App中动态生成图片后显示,需加上代码判断不同屏幕设备来获取/生成不同size图片。 if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2){ //retina 或 ipad上 ...
ccTouchesBegan 中如何让获取的坐标是相对整个屏幕的坐标,而不是在当前view的坐标          在cocos2d中,在我们在CCLayer中处理 ccTouchesBegan等类似的touch事件的时候,我们一般用下面的代码来获得当前的用户点击位置:        UITouch *touch=[touches anyObject]; CGPoint touchLocation= [touch locationInView:[touch view]]; CGPoint glLocation=[[CCDirector sharedD ...
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; CGPoint p1 = [touch locationInView:nil]; //p1.y = 480-p1.y; CGPoint p3 = [self convertToNodeSpace:[[CCDirector sharedDirector] convertToGL:p1]]; CGRect rect = [self.pla ...
首先:如果alloc一个对象就必须要释放代码 比如: Test *t = [[Test alloc] init]; Test1.t = t; [t release]; 或者 Test1.t = [[[Test alloc] init] autorelease]; 在dealloc释放中,不要使用self去得到对象 请用下划线+属性名去得到对象 - (void)dealloc{ [_t release]; [super release]; }
新建一个cocos2d-chipmunk项目 首先AppDelegate.m中加入 - (void)applicationDidFinishLaunching:(UIApplication *)application{ cpInitChipmunk(); } 初始化!! 然后添加类 TestWorld.h // // TestWorld.h // TestPiking // // Created by Rayln Guan on 10/3/13. // Copyright 2013 __MyCompanyName__. All rights reserved. ...
在.m文件中加入 #ifdef _FOR_DEBUG_ -(BOOL) respondsToSelector:(SEL)aSelector { printf("SELECTOR: %s\n", [NSStringFromSelector(aSelector) UTF8String]); return [super respondsToSelector:aSelector]; } #endif 然后在 other c flags中加入-D _FOR_DEBUG_(记住请只在Debug Configuration下加入此标记)。这样当你程序崩溃时, ...
IOS中支持多线程操作,使用NSThread和NSInvocationOperation可以完成多线程功能。多线程的功能主要是为了防止阻塞主线程的工作(主要是UI操作和显示),使一些耗时的的操作在另一个线程中完成,完成后可以通知主线程来进行UI上的更新。多线程功能在实际开发中用的很多,最典型的就是网络请求和处理操作,下面主要来讨论一下Cocoa中的NSThread和NSInvocationOperation: 一、NSThread 创建NSThread主要有两种方式: 1.使用类方法创建 [NSThread detachNewThreadSelector:@selector(doInBa ...
// // Player.m // Test2 // // Created by rayln on 13-9-29. // Copyright 2013年 __MyCompanyName__. All rights reserved. // #import "Player.h" @implementation Player - (id)init{ self = [super init]; if(self){ CCSpriteBatchNode* path = [CCSprite ...

CC的各种动画

一共由几种 CCMoveBy CCMoveTo CCScaleBy CCScaleTo CCRotateBy CCRotateTo CCSkewBy CCSkewTo CCTintBy CCTintTo CCJumpBy CCJumpTo CCHide CCShow CCFadeIn CCFadeout CCToggleVisibility CCCallFunc //回掉函数 CCCallFunc::create(this, callfunc_selector(HellWorld::test)) CCDelayTime //延迟时间 CCSequence //顺序播放动画 CCSpawn / ...
[self.plane setPosition:CGPointMake(200, 100)]; CCSprite *s = [CCSprite spriteWithFile:@"ccbParticleFire.png"]; [s setPosition:CGPointMake(100, 100)]; [self addChild:s]; CCMoveBy *action1 = [CCMoveBy actionWithDuration:1 position:CGPointMake(30, 30)]; CCMoveTo ...

CCSprit使用

CCSprite *s = [CCSprite spriteWithFile:@"ccbParticleFire.png"]; [s setPosition:CGPointMake(100, 100)]; [self addChild:s]; //进行移动操作 [s runAction:[CCMoveBy actionWithDuration:10 position:CGPointMake(100, 100)]];

CCLayer场景切换

CCScene* scene = [CCBReader sceneWithNodeGraphFromFile:@"Test1.ccbi"]; [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:scene withColor:ccWHITE]]; 切换到Test1.ccbi的场景
// // ViewController.h // datastore // // Created by Rayln Guan on 9/25/13. // Copyright (c) 2013 Rayln Guan. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UITextField *username; @property (wea ...
通过UITabBarController去实现多页面切换效果 例子 // // AppDelegate.h // Tab1 // // Created by Rayln Guan on 9/24/13. // Copyright (c) 2013 Rayln Guan. All rights reserved. // #import <UIKit/UIKit.h> @class ViewController; @class SecondViewController; @interface AppDelegate : UIResponder & ...
Global site tag (gtag.js) - Google Analytics