예제 #1
0
void GamePlayScene::initNavigator() {
    MenuItemFont *menuTitle = MenuItemFont::create(Constant::MENU_PLAY, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
    menuTitle->setFontName(Constant::FONT);
    menuTitle->setFontSize(64);
    menuTitle->setVisible(false);

    MenuItemFont *back = MenuItemFont::create(Constant::MENU_BACK, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
    back->setFontName(Constant::FONT);
    back->setFontSize(64);
    back->setTag(Constant::MENU_BACK_TAG);

    MenuItemFont *start = MenuItemFont::create(Constant::MENU_START, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
    start->setFontName(Constant::FONT);
    start->setFontSize(64);
    start->setTag(Constant::MENU_START_TAG);

    Menu *menu = Menu::create(back, start, NULL);
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    back->setPosition(Vec2(origin.x + visibleSize.width - back->getContentSize().width / 2,
                                    origin.y + back->getContentSize().height / 2));
    start->setPosition(Vec2(origin.x + start->getContentSize().width / 2,
                                    origin.y + back->getContentSize().height / 2));
    menu->setPosition(Vec2::ZERO);
    addChild(menu);
}
예제 #2
0
// ゲームメイン処理
void PlayScene::gameLogic(){
    // 画像描画用に画面のサイズと座標開始位置を取得
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    // ゲームオブジェクトの追加とそのアニメーション処理
    schedule(schedule_selector(PlayScene::addGameObject), 2.0);
    

    // クリアボタン作成
    MenuItemFont* clearButton = MenuItemFont::create("CLEAR!",
                                                      [this](Ref *pSender){
                                                          float duration = 1.0f;
                                                          Scene* pScene = TransitionFadeDown::create(duration, EndingScene::createScene());
                                                          Director::getInstance()->replaceScene(pScene);
                                                      });
    
    
    clearButton->setPosition(Vec2(origin.x + ( visibleSize.width / 3) * 2 + ( clearButton->getContentSize().width / 2 ) ,
                                  origin.y + ( visibleSize.height / 5) * 2 ));
    
    // ゲームオーバーボタン作成
    MenuItemFont* gameOverButton = MenuItemFont::create("GAMEOVER!",
                                                     [this](Ref *pSender){
                                                         float duration = 1.0f;
                                                         Scene* pScene = TransitionJumpZoom::create(duration, GameOverScene::createScene());
                                                         Director::getInstance()->replaceScene(pScene);
                                                     });
    
    
    gameOverButton->setPosition(Vec2(origin.x + ( visibleSize.width / 3) * 2 + ( gameOverButton->getContentSize().width / 2 ) ,
                                     origin.y + ( visibleSize.height / 5) * 3));

    
    
    // 作成したボタンの追加
    Menu* menu = Menu::create(clearButton, gameOverButton, NULL);
    menu->setPosition(0,0);
    this->addChild(menu);
}
예제 #3
0
// on "init" you need to initialize your instance
bool TestIAP::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    MyPurchase::getInstance()->loadIAPPlugin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    auto pEGLView = Director::getInstance()->getOpenGLView();
    Point posBR = Point(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
    Point posTL = Point(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);

    // add a "close" icon to exit the progress. it's an autorelease object
    MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAP::menuBackCallback, this));
    Size backSize = pBackItem->getContentSize();
    pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));

    // create menu, it's an autorelease object
    Menu* pMenu = Menu::create(pBackItem, NULL);
    pMenu->setPosition( Point::ZERO );
    this->addChild(pMenu, 1);

    Point posStep = Point(220, -150);
    Point beginPos = posTL + (posStep * 0.5f);
    int line = 0;
    int row = 0;
    for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
    	MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(),
    			CC_CALLBACK_1(TestIAP::eventMenuCallback, this));
        pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);

        Point pos = beginPos + Point(posStep.x * row, posStep.y * line);
        Size itemSize = pMenuItem->getContentSize();
        if ((pos.x + itemSize.width / 2) > posBR.x)
		{
			line += 1;
			row = 0;
			pos = beginPos + Point(posStep.x * row, posStep.y * line);
		}
        row += 1;
        pMenuItem->setPosition(pos);
    }

    return true;
}
예제 #4
0
bool MDPauseMenu::init(MDPauseMenuInterfaz* target)
{
    if (CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)) )
    {
        mTarget = target;
        
        Size visibleSize  = Director::getInstance()->getVisibleSize();
        
        // Menu items
        MenuItemFont *btResume = MenuItemFont::create("Resume",
                                                          this,
                                                          menu_selector(MDPauseMenu::resumeGame));
        btResume->setColor(ccc3(255, 255, 255));
        btResume->setAnchorPoint(ccp(0.5, 1));
		btResume->setPosition(ccp(0, 0));
        
        MenuItemFont *btRetry = MenuItemFont::create("Retry",
                                                          this,
                                                          menu_selector(MDPauseMenu::retryGame));
        btRetry->setColor(ccc3(255, 255, 255));
		btRetry->setAnchorPoint(ccp(0.5, 1));
		btRetry->setPosition(ccp(0, btResume->getPosition().y - btResume->getContentSize().height - MENU_ITEMS_SPACING));

        MenuItemFont *btExit = MenuItemFont::create("Exit",
                                                          this,
                                                          menu_selector(MDPauseMenu::quitGame));
        btExit->setColor(ccc3(255, 255, 255));
		btExit->setAnchorPoint(ccp(0.5, 1));
		btExit->setPosition(ccp(0, btRetry->getPosition().y - btRetry->getContentSize().height - MENU_ITEMS_SPACING));
        
        // Menu
        Menu *menu = Menu::create(btResume, btRetry, btExit, NULL);
		menu->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
        addChild(menu);
        
        return true;
    }
    return false;
}
// on "init" you need to initialize your instance
bool TestAnalytics::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    _pluginAnalytics = NULL;
    loadPlugins();

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();
    Point posBR = Point(origin.x + visibleSize.width, origin.y);

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAnalytics::menuBackCallback, this));
    Size backSize = pBackItem->getContentSize();
    pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));

    // create menu, it's an autorelease object
    Menu* pMenu = Menu::create(pBackItem, NULL);
    pMenu->setPosition( Point::ZERO );
    this->addChild(pMenu, 1);

    float yPos = 0;
    for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
        LabelTTF* label = LabelTTF::create(s_EventMenuItem[i].id.c_str(), "Arial", 24);
        MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestAnalytics::eventMenuCallback, this));
        pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
        yPos = visibleSize.height - 35*i - 100;
        pMenuItem->setPosition( Point(visibleSize.width / 2, yPos));
    }

    std::string strName = _pluginAnalytics->getPluginName();
    std::string strVer = _pluginAnalytics->getSDKVersion();
    char ret[256] = { 0 };
    sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str());
    LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, Point(visibleSize.width, 0), Label::HAlignment::CENTER);
    pLabel->setPosition(Point(visibleSize.width / 2, yPos - 80));
    addChild(pLabel);

    return true;
}
예제 #6
0
bool ListLayer::init() {
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();
    Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
    Point posBR = Point(origin.x + visibleSize.width, origin.y);
    Point posBL = Point(origin.x, origin.y);
    
    
    MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(ListLayer::onBackCallback, this));
    Size backSize = pBackItem->getContentSize();
    pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));
    
    MenuItemFont *pMenuItem = MenuItemFont::create("Menu", CC_CALLBACK_1(ListLayer::onMenuCallback, this));
    Size menuSize = pMenuItem->getContentSize();
    pMenuItem->setPosition(posBL + Point(menuSize.width / 2, menuSize.height / 2));
    
    Menu* pMenu = Menu::create(pBackItem, pMenuItem, nullptr);
    pMenu->setPosition(Point::ZERO);
    addChild(pMenu, 1);
    
    _testListView = TableView::create(this, visibleSize);
    _testListView->setDelegate(this);
    _testListView->setPosition(posBL);
    _testListView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
    
    addChild(_testListView);
    
    return true;
}
void StoreScene::showInGameMenuLayer() {
	Size winSize = Director::getInstance()->getWinSize();

	InGameMenuLayer* _inGameMenuLayer = InGameMenuLayer::create();
	addChild(_inGameMenuLayer);

	MenuItemFont *menuButton = MenuItemFont::create("Menu", this,menu_selector(StoreScene::menuButtonCallback));
	menuButton->setColor(Color3B(0,0,0));

	menuButton->setPosition(Point(winSize.width - menuButton->getContentSize().width, winSize.height - menuButton->getContentSize().height));

	Menu *pMenu = Menu::create(menuButton,NULL);
	pMenu->setPosition(Point::ZERO);

	_inGameMenuLayer->addChild(pMenu, 1);
}
예제 #8
0
// on "init" you need to initialize your instance
bool TestSocial::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    MySocialManager::getInstance()->loadPlugins();

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();
    Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
    Point posBR = Point(origin.x + visibleSize.width, origin.y);

    MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestSocial::menuBackCallback, this));
    Size backSize = pBackItem->getContentSize();
    pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));

    // create menu, it's an autorelease object
    Menu* pMenu = Menu::create(pBackItem, NULL);
    pMenu->setPosition( Point::ZERO );

    LabelTTF* label1 = LabelTTF::create("Submit Score", "Arial", 28);
    MenuItemLabel* pItemSubmit = MenuItemLabel::create(label1, CC_CALLBACK_1(TestSocial::testSubmit, this));
    pItemSubmit->setAnchorPoint(Point(0.5f, 0));
    pMenu->addChild(pItemSubmit, 0);
    pItemSubmit->setPosition(posMid + Point(-140, -60));

    LabelTTF* label2 = LabelTTF::create("Unlock Achievement", "Arial", 28);
    MenuItemLabel* pItemUnlock = MenuItemLabel::create(label2, CC_CALLBACK_1(TestSocial::testUnlock, this));
    pItemUnlock->setAnchorPoint(Point(0.5f, 0));
    pMenu->addChild(pItemUnlock, 0);
    pItemUnlock->setPosition(posMid + Point(140, -60));

    LabelTTF* label3 = LabelTTF::create("Show Leaderboard", "Arial", 28);
    MenuItemLabel* pItemLeader = MenuItemLabel::create(label3, CC_CALLBACK_1(TestSocial::testLeaderboard, this));
    pItemLeader->setAnchorPoint(Point(0.5f, 0));
    pMenu->addChild(pItemLeader, 0);
    pItemLeader->setPosition(posMid + Point(-140, -120));

    LabelTTF* label4 = LabelTTF::create("Show Achievement", "Arial", 28);
    MenuItemLabel* pItemAchi = MenuItemLabel::create(label4, CC_CALLBACK_1(TestSocial::testAchievement, this));
    pItemAchi->setAnchorPoint(Point(0.5f, 0));
    pMenu->addChild(pItemAchi, 0);
    pItemAchi->setPosition(posMid + Point(140, -120));

    // create optional menu
    // cases item
    _caseItem = MenuItemToggle::createWithCallback(NULL,
                                                MenuItemFont::create( s_aTestCases[0].c_str() ),
                                                NULL );
    int caseLen = sizeof(s_aTestCases) / sizeof(std::string);
    for (int i = 1; i < caseLen; ++i)
    {
        _caseItem->getSubItems().pushBack( MenuItemFont::create( s_aTestCases[i].c_str() ) );
    }
    _caseItem->setPosition(posMid + Point(0, 120));
    pMenu->addChild(_caseItem);

    this->addChild(pMenu, 1);

    return true;
}
예제 #9
0
// on "init" you need to initialize your instance
bool TestAds::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    _listener = new MyAdsListener();
    _admob = dynamic_cast<ProtocolAds*>(PluginManager::getInstance()->loadPlugin("AdsAdmob"));
    _flurryAds = dynamic_cast<ProtocolAds*>(PluginManager::getInstance()->loadPlugin("AdsFlurry"));
    TAdsDeveloperInfo devInfo;
    
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
    devInfo["AdmobID"] = ADMOB_ID_IOS;
    devInfo["FlurryAppKey"] = FLURRY_KEY_IOS;
#elif CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
    devInfo["AdmobID"] = ADMOB_ID_ANDROID;
    devInfo["FlurryAppKey"] = FLURRY_KEY_ANDROID;
#endif
    
    _admob->configDeveloperInfo(devInfo);
    _admob->setAdsListener(_listener);
    _admob->setDebugMode(true);

    _flurryAds->configDeveloperInfo(devInfo);
    _flurryAds->setAdsListener(_listener);
    _flurryAds->setDebugMode(true);

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();
    Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
    Point posBR = Point(origin.x + visibleSize.width, origin.y);

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAds::menuBackCallback, this));
    Size backSize = pBackItem->getContentSize();
    pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));

    // create menu, it's an autorelease object
    Menu* pMenu = Menu::create(pBackItem, NULL);
    pMenu->setPosition( Point::ZERO );

	LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24);
	MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(TestAds::testShow, this));
	pItemShow->setAnchorPoint(Point(0.5f, 0));
	pMenu->addChild(pItemShow, 0);
	pItemShow->setPosition(posMid + Point(-100, -120));

	LabelTTF* label2 = LabelTTF::create("HideAds", "Arial", 24);
	MenuItemLabel* pItemHide = MenuItemLabel::create(label2, CC_CALLBACK_1(TestAds::testHide, this));
	pItemHide->setAnchorPoint(Point(0.5f, 0));
	pMenu->addChild(pItemHide, 0);
	pItemHide->setPosition(posMid + Point(100, -120));

	// create optional menu
	// cases item
	_caseItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestAds::caseChanged, this),
												MenuItemFont::create( s_aTestCases[0].c_str() ),
												NULL );
	int caseLen = sizeof(s_aTestCases) / sizeof(std::string);
	for (int i = 1; i < caseLen; ++i)
	{
		_caseItem->getSubItems()->addObject( MenuItemFont::create( s_aTestCases[i].c_str() ) );
	}
	_caseItem->setPosition(posMid + Point(-200, 120));
	pMenu->addChild(_caseItem);

	// poses item
	_posItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestAds::posChanged, this),
												MenuItemFont::create( s_aTestPoses[0].c_str() ),
												NULL );
	int posLen = sizeof(s_aTestPoses) / sizeof(std::string);
	for (int i = 1; i < posLen; ++i)
	{
		_posItem->getSubItems()->addObject( MenuItemFont::create( s_aTestPoses[i].c_str() ) );
	}
	_posItem->setPosition(posMid + Point(200, 120));
	pMenu->addChild(_posItem);

	// init options
	_ads = _admob;
	_pos = ProtocolAds::kPosCenter;

    // init the AdsInfo
    adInfo["AdmobType"] = "1";
    adInfo["AdmobSizeEnum"] = "1";
    adInfo["FlurryAdsID"] = "BANNER_MAIN_VC";
    adInfo["FlurryAdsSize"] = "2";

    this->addChild(pMenu, 1);

    return true;
}