cocos2d-xハンズオンを受けたのでメモ
頭にCCがつくのが最初気持ち悪かった。
iOSの開発やってる人は馴染みやすそう。
クロスプラットフォーム開発すげぇ!
Unityよりも固めたアプリが軽量。
// シングルタップでは必ずoverride virtual bool ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent); // cocosのタッチポイントをopenGLのタップポイントにする。touchPointは構造体(x, y) CCPoint touchPoint = CCDirector::sharedDirector()->convertToGL(pTouch->getLocationInView()); // 指定された四角形の中にタッチポイントが含まれているかどうかをtruefalseで返す node->boundingBox().containsPoint( // フォントの指定で空にするとシステムフォント CCLabelTTF* timerLabel = CCLabelTTF::create("0.000s", "", 32.0f);touchPoint) // CCDirectorはシングルトンになっている。画面を統括する唯一のクラス。sharedDirectorでインスタンスを取得してgetWinSizeで画面サイズ取得 CCSize bgSize = CCDirector::sharedDirector()->getWinSize(); // scheduleを使うと毎フレーム呼び出す this->schedule(schedule_selector(HelloWorld::countTimer)); // getChildByTagの返り値がnodeなのでキャストする CCLabelTTF* timerLabel = (CCLabelTTF*)this->getChildByTag(kTagTimerLabel); // flush()までやってsetしたものが次回使えるようになる CCUserDefault::sharedUserDefault()->setFloatForKey("highscore", gameTime); CCUserDefault::sharedUserDefault()->flush(); // ボタンが10こあったら最後にNULLを入れる CCMenu* menu = CCMenu::create(retryLabel, NULL);