const std::string testsName[MAX_COUNT] =
{
"Bug-350",
"Bug-422",
"Bug-458",
"Bug-624",
"Bug-886",
"Bug-899",
"Bug-914",
"Bug-1159",
"Bug-1174"
};
void ExtensionsMainLayer::onEnter()
{
CCLayer::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize();
//创建菜单按钮列表
CCMenu* pMenu = CCMenu::create();
pMenu->setPosition( CCPointZero );
//设置子菜单项的字体和大小
CCMenuItemFont::setFontName("Arial");
CCMenuItemFont::setFontSize();
for (int i = ; i < TEST_MAX_COUNT; ++i)
{
//创建子菜单,并且每个子菜单都绑定同一个函数
CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this,
menu_selector(ExtensionsMainLayer::menuCallback));
pItem->setPosition(ccp(s.width / , s.height - (i + ) * LINE_SPACE));
//添加到层中
pMenu->addChild(pItem, kItemTagBasic + i);
} addChild(pMenu);
}
void ExtensionsMainLayer::menuCallback(CCObject* pSender)
{
CCMenuItemFont* pItem = (CCMenuItemFont*)pSender;
int nIndex = pItem->getZOrder() - kItemTagBasic; switch (nIndex)
{
case TEST_NOTIFICATIONCENTER:
{
runNotificationCenterTest();
}
break;
case TEST_CCCONTROLBUTTON:
{
CCControlSceneManager* pManager = CCControlSceneManager::sharedControlSceneManager();
CCScene* pScene = pManager->currentControlScene();
CCDirector::sharedDirector()->replaceScene(pScene);
}
break;
case TEST_COCOSBUILDER:
{
TestScene* pScene = new CocosBuilderTestScene();
if (pScene)
{
pScene->runThisTest();
pScene->release();
}
}
break;
case TEST_HTTPCLIENT:
{
runHttpClientTest();
}
break;
//在ios和android平台下可以调用
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
case TEST_EDITBOX:
{
runEditBoxTest();
}
break;
#endif
case TEST_TABLEVIEW:
{
runTableViewTest();
}
break;
default:
break;
}
}
05-11 23:04