void MenuLayerMainMenu::menuCallback(CCObject* pSender)
{
	CCLOG("menuCallback called");

	// get the userdata, it's the index of the menu item clicked
	CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
	int nIdx = pMenuItem->getZOrder() - 1000;

	// create the test scene and run it
	switch (nIdx)
	{
	case 1:
		{
			CCLOG("new game clicked");

			CCScene* scene=CCScene::create();
			CCLayer* layer=MenuLayerPlayerSelect::create();
			scene->addChild(layer,0);
			CCDirector::sharedDirector()->pushScene(CCTransitionSlideInT::create(1,scene));

			break;

		}
		
	case 2:
		CCLOG("load game clicked");
		break;

	case 6:
		CCDirector::sharedDirector()->end();
	default:
		break;
	}
}
void GameMenuLayer::menuCallback(CCObject* pSender)
{
	CCMenuItem* menuItem = (CCMenuItem*)(pSender);
	int nIdx = menuItem->getZOrder()-1000;

	if (nIdx == GAME_MENU_START)
	{
		GameScene* pScene = new GameScene();
		pScene->runThisTest();
		pScene->release();
	}
}
Exemple #3
0
void TestController::menuCallback(CCObject * pSender)
{
    // get the userdata, it's the index of the menu item clicked
    CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
    int nIdx = pMenuItem->getZOrder() - 10000;
    // create the test scene and run it
    TestScene* pScene = CreateTestScene(nIdx);
    if (pScene)
    {
        pScene->runThisTest();
        pScene->release();
    }
}
//--------------------------------------------------------
void CListControllerLayer::menuCallback(CCObject * pSender)
{
	CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
	int nIdx = pMenuItem->getZOrder() - 10000;

	// 创建并执行子场景
	string szSceneClassName = GetSceneClassName(static_cast<ENUM_TEST_SCENE_TYPE>(nIdx));
	if ( szSceneClassName != "" )
	{
		FKCOLORLOG( eConsolBKColor_Gray | eConsolTextColor_Red , "尝试创建 : %s", szSceneClassName.c_str() );
		FKCW_SceneExMgr_SceneExMgr::sharedManager()->pushScene(LoadScene(szSceneClassName.c_str()));
	}
}
void TitleScene::menuCallback(CCObject* pSender)
{
    // get the userdata, it's the index of the menu item clicked
    CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
    int nIdx = pMenuItem->getZOrder() - 10000;
    
    CCLog("Index = %d", nIdx);
    
    if (nIdx == ITEM_COUNT - 1)
    {
        // last item in the list is exit
        CCDirector::sharedDirector()->end();
        
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        exit(0);
#endif
    }
    else
    {
        // create the scene and run it
        CCScene *pScene = NULL;
        switch (nIdx)
        {
        case 0:
            pScene = GameScene::scene(); break;
        case 1:
            pScene = HelloWorld::scene(); break;
        default:
            break;
        }
        
        // run
        if (pScene)
        {
            CCDirector::sharedDirector()->replaceScene(pScene);
        }
    }
    
}
void CocosDenshionTest::menuCallback(CCObject * pSender)
{
    // get the userdata, it's the index of the menu item clicked
    CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
    int nIdx = pMenuItem->getZOrder() - 10000;

    switch(nIdx)
    {
    // play background music
    case 0:

        SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(MUSIC_FILE)).c_str(), true);
        break;
    // stop background music
    case 1:
        SimpleAudioEngine::sharedEngine()->stopBackgroundMusic();
        break;
    // pause background music
    case 2:
        SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
        break;
    // resume background music
    case 3:
        SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
        break;
    // rewind background music
    case 4:
        SimpleAudioEngine::sharedEngine()->rewindBackgroundMusic();
        break;
    // is background music playing
    case 5:
        if (SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())
        {
            CCLOG("background music is playing");
        }
        else
        {
            CCLOG("background music is not playing");
        }
        break;
    // play effect
    case 6:
        m_nSoundId = SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE)).c_str());
        break;
    // play effect
    case 7:
        m_nSoundId = SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE)).c_str(), true);
        break;
    // stop effect
    case 8:
        SimpleAudioEngine::sharedEngine()->stopEffect(m_nSoundId);
        break;
    // unload effect
    case 9:
        SimpleAudioEngine::sharedEngine()->unloadEffect(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE)).c_str());
        break;
        // add bakcground music volume
    case 10:
        SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() + 0.1f);
        break;
        // sub backgroud music volume
    case 11:
        SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() - 0.1f);
        break;
        // add effects volume
    case 12:
        SimpleAudioEngine::sharedEngine()->setEffectsVolume(SimpleAudioEngine::sharedEngine()->getEffectsVolume() + 0.1f);
        break;
        // sub effects volume
    case 13:
        SimpleAudioEngine::sharedEngine()->setEffectsVolume(SimpleAudioEngine::sharedEngine()->getEffectsVolume() - 0.1f);
        break;
    case 14:
        SimpleAudioEngine::sharedEngine()->pauseEffect(m_nSoundId);
        break;
    case 15:
        SimpleAudioEngine::sharedEngine()->resumeEffect(m_nSoundId);
        break;
    case 16:
        SimpleAudioEngine::sharedEngine()->pauseAllEffects();
        break;
    case 17:
        SimpleAudioEngine::sharedEngine()->resumeAllEffects();
        break;
    case 18:
        SimpleAudioEngine::sharedEngine()->stopAllEffects();
        break;
    }
    
}
void TestLayer::menuCallback(CCObject * pSender)
{
    CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
    this->testLogic(pMenuItem->getZOrder());
}
Exemple #8
0
void SuDoKuLayer::menuCallback(CCObject* pSender) {
	// 获得用户的数据,即菜单的索引
	CCMenuItem* pMenuItem = (CCMenuItem *) (pSender);
	int nIdx = pMenuItem->getZOrder();
	CCLog("Zorder %d\n", nIdx);
}