Archive for the ‘cocos2d-x’ Category

 

menuの使い方 cocos2d-x v3

3月 13th, 2014

シーン入れ替えサンプルより ヘッダー public: void onPushScene(Object* sender); auto item1 = MenuItemFont::create( “Test pushScene”, CC_CALLBACK_1(SceneTestLayer1::onPushScene, this)); auto item2 = MenuItemFont::create( “Test pushScene w/transition”, CC_CALLBACK_1(SceneTestLayer1::onPushSceneTran, this)); auto item3 = MenuItemFont::create( “Quit”, CC_CALLBACK_1(SceneTestLayer1::onQuit, this)); // 色 item3->setColor(Color3B( 255,0,0 )); auto menu = Menu::create( item1, item2, item3, NULL ); menu->alignItemsVertically(); addChild( menu ); こんな感じで、OKでした。

Read full article | コメントは受け付けていません。

タッチイベント取得 cocos2d-x v3

3月 13th, 2014

http://www.cocos2d-x.org/docs/manual/framework/native/input/event-dispatcher/en auto touchListener = EventListenerTouchOneByOne::create(); touchListener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded, this); touchListener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); _eventDispatcherはNodeにあるのでそのまま使えるようです。 タッチされたかチェック Point touchPoint = Director::getInstance()->convertToGL(touch->getLocationInView()); Node* node = this->getChildByTag( targetTag ); if ( node->getBoundingBox().containsPoint(touchPoint) ){ log(“touchEnded %d” , nextNumber); こんな感じで動きました。

Read full article | コメントは受け付けていません。

cocos2d-x 始めました。1

3月 3rd, 2014

html5は少し書きましたが、とりあえず一つアプリを作ってみようと思います。 1. ダウンロードします。 http://www.cocos2d-x.org/ v3.0beta2 2.xと3.0は命名とかかなり変わっているようなのでbetaですが3.0にしてみました。 334MBあるようです。 README.mdに言われるがママ $ cd proj.android/ $ ./build_native.py NDK_ROOT not defined. Please define NDK_ROOT in your environment c++なのでandroid-ndkというのが必要だそうです http://developer.android.com/tools/sdk/ndk/index.html ダウンロードした物を解凍して移動しておく $ mv android-ndk-r9c /Applications/android/ ./bash_profileに NDK_ROOT=/Applications/android/android-ndk-r9c と書いておいた。 とりあえずandroid sdkを最新にしてみる $ cd Applications/android/android-sdk/ $ ./tools/android update sdk –no-ui もう一度。 $ cd proj.android/ $ ./build_native.py The Selected NDK toolchain version was 4.8 […]

Read full article | コメントは受け付けていません。