Ming Apps

Cocos2d for iPhone – 第一篇!

Posted on: 2011/03/30

Cocos2d for iPhone Logo

原本網頁: http://www.cocos2d-iphone.org/

一個月前,FYP的topic由html5 web apps轉做iPad apps,

真的徬徨無助哈~

 

找了很多很多objective-c framework,

朋友介紹了這一個framework.

Fast, Free, Easy to Use, Community supported.

Google一下你的問題再加"cocos2d“做keywords,

好多問題都解決了~

有唔少Class會經常用到:

CCLayer / CCLayerColor(舊有的ClassName為CCColorLayer): Layer that receive touches and 設定初始背景顏色!

CCLayerColor *layer = [[CCLayerColor alloc] init];
[layer setColor: ccc4(255, 255, 255, 255)];

CCMenu / CCMenuItem: Default了一堆方便你堆砌Menu既Class!

[CCMenuItemFont setFontName:@"Helvetica"];

CCMenuItem *menuItem1 = [CCMenuItemFont itemFromString:@"HelloWorld" target:self selector:@selector(scene1:)];
CCMenuItem *menuItem2 = [CCMenuItemFont itemFromString:@"Test"];
CCMenu *menu = [CCMenu menuWithItems:menuItem1, menuItem2,nil];

[menu alignItemsVertically];
[menu setPosition:ccp(240, 160)];
[self addChild:menu];

CCLabelTTF(舊有的ClassName為CCLabel/Label):  故名思義, 就是LabelText, 純粹Display String/ Display Text

CCLabelTTF *test = [CCLabelTTF labelWithString:@"Testing" fontName:@"Marker Felt" fontSize:16];
 [self addChild:test];

CCSprite: Google了Sprite的解釋,是指小精靈/小妖精。如果你寫Game, 我會當佢做一個人物角色,可以任意係畫面複製角色於Layer / RenderTexture 上。

CCDirector: 導演一名,可設定Frame per second既時間,加速減速自己決定。

[[CCDirector sharedDirector] setAnimationInterval:1/240.0];

 

暫時已經support Xcode 3 & Xcode 4,

雖然仍在develop階段,

但好期待佢去version 1.0既正式版!

之後的Blog應該會有更多cocos2d的介紹!

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

%d 位部落客按了讚: