Upload
tomoaki-shimizu
View
21.316
Download
2
Embed Size (px)
DESCRIPTION
Cocos2d-xを用いて簡単なゲームを作ってみる
Citation preview
Cocos2d-xで簡単なゲームを作ってみよう!
株式会社TKS2 清水友晶
清水 友晶(株)TKS2
スマートフォンアプリ開発iOS, Android, (Windows Phone 8)WebコンテンツTwitter: tks2shimizufacebook:http://www.facebook.com/doraemonsssslide share:http://www.slideshare.net/doraemonsss
2
目次ゲームの説明必要なクラスの説明ゲーム作成カードの配置カードのタップ時間表示ハイスコア表示ゲームのリトライ
4
19:30
20:2020:4021:0021:2021:40
ゲームの説明1から25まで順番にタップするカードゲーム今回の対象はiPhone4を想定iPhoneシミュレータではiPhone(Retina 3.5inch)
5
カードの配置に必要なクラスの説明CCSpriteクラス
create関数
setPosition関数
setTag関数
6
CCSprite* button = CCSprite::create("xxx.png");
button->setPosition(ccp(100,200));
button->setTag(10);
カードの配置に便利なクラスの説明CCStringクラス
create関数
createWithFormat関数
7
CCString* string = CCString::create("xxxxxx");
CCString* string = CCString::createWithFormat( "frontside%02d.png", 10);
カードのタップに必要なクラスの説明CCLayerクラス
setTouchEnabled関数
8
とすると、
this->setTouchEnabled(true);this->setTouchMode(kCCTouchesOneByOne);
カードのタップに必要なクラスの説明
タップ時に次のイベントが発生するccTouchBegan関数ccTouchMoved関数ccTouchEnded関数ccTouchCancelled関数
マルチタップは別の関数9
時間カウントに必要なクラスの説明CCNodeクラス
schedule関数
countTimer関数(関数名は任意)
10
this->schedule( schedule_selector( HelloWorld::countTimer));
voidHelloWorld::countTimer(float time) { gameTime += time;}
時間カウントに必要なクラスの説明CCNodeクラス
unschedule関数
11
this->unschedule( schedule_selector( HelloWorld::countTimer));
永続データに必要なクラスの説明CCUserDefaultクラス(シングルトン)
getFloatForKey関数
setFloatForKey関数flush関数
12
float hoge = CCUserDefault::sharedUserDefault()-> getFloatForKey("xxx", 0);
CCUserDefault::sharedUserDefault()-> setFloatForKey("xxx", 10.5f);CCUserDefault::sharedUserDefault()-> flush();
ボタンの作成に必要なクラスの説明CCMenuItemFontクラス
create関数
CCMenuクラス
13
CCMenuItemFont* item = CCMenuItemFont::create( "xxx", this, menu_selector(HelloWorld::yyy));
CCMenu* menu = CCMenu::create(item, NULL);menu->setPosition(CCPointZero);this->addChild(menu);
ゲームを作ってみよう!
まずはカードの配置20:20に解説
14
カードのダウンロードはhttp://tks2.net/other/cards.zip
ここまでのコードカードの配置https://gist.github.com/4239354
次はカードのタップ20:40に解説
15
カードのダウンロードはhttp://tks2.net/other/cards.zip
ここまでのコードカードのタップhttps://gist.github.com/4239351
次は時間表示21:00に解説
16
カードのダウンロードはhttp://tks2.net/other/cards.zip
ここまでのコード時間表示https://gist.github.com/4239350
次はハイスコア表示21:20に解説
17
カードのダウンロードはhttp://tks2.net/other/cards.zip
ここまでのコードハイスコア表示https://gist.github.com/4239338
次はゲームのリトライ21:40に解説
18
カードのダウンロードはhttp://tks2.net/other/cards.zip
できあがりのコード
できあがりhttps://gist.github.com/4238817
19
今後の予定
Cocos2d-xをもっとさわってみるCocos2d-xの拡張外部ツールの利用Box2Dの利用OSとの連携
20