void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) { //std::srand(time()); auto s = Director::getInstance()->getWinSize(); lastRenderedCount = 0; currentQuantityOfNodes = 0; quantityOfNodes = nNodes; MenuItemFont::setFontSize(65); auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { quantityOfNodes -= kNodesIncrease; if( quantityOfNodes < 0 ) quantityOfNodes = 0; updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); std::srand(0); }); decrease->setColor(Color3B(0,200,20)); auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { quantityOfNodes += kNodesIncrease; if( quantityOfNodes > kMaxNodes ) quantityOfNodes = kMaxNodes; updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); std::srand(0); }); increase->setColor(Color3B(0,200,20)); auto menu = Menu::create(decrease, increase, nullptr); menu->alignItemsHorizontally(); menu->setPosition(Vec2(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30); infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Vec2(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); std::srand(0); }
void NodeChildrenMainScene::dumpProfilerInfo(float dt) { CC_PROFILER_DISPLAY_TIMERS(); if (this->isAutoTesting()) { // record the test result to class Profile auto timer = Profiler::getInstance()->_activeTimers.at(_profilerName); auto numStr = genStr("%d", quantityOfNodes); auto avgStr = genStr("%ldµ", timer->_averageTime2); auto minStr = genStr("%ldµ", timer->minTime); auto maxStr = genStr("%ldµ", timer->maxTime); Profile::getInstance()->addTestResult(genStrVector(getTestCaseName().c_str(), numStr.c_str(), nullptr), genStrVector(avgStr.c_str(), minStr.c_str(), maxStr.c_str(), nullptr)); auto testsSize = sizeof(autoTestNodesNums)/sizeof(int); if (autoTestIndex >= (testsSize - 1)) { // if it's the last one of auto test. End the auto test. this->setAutoTesting(false); Profile::getInstance()->testCaseEnd(); } else { // update the auto test index autoTestIndex++; quantityOfNodes = autoTestNodesNums[autoTestIndex]; updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); } } }
void ParticleMainScene::onDecrease(CCObject* pSender) { quantityParticles -= kNodesIncrease; if( quantityParticles < 0 ) quantityParticles = 0; updateQuantityLabel(); createParticleSystem(); }
void ParticleMainScene::onIncrease(CCObject* pSender) { quantityParticles += kNodesIncrease; if( quantityParticles > kMaxParticles ) quantityParticles = kMaxParticles; updateQuantityLabel(); createParticleSystem(); }
void NodeChildrenMainScene::onIncrease(CCObject* pSender) { quantityOfNodes += kNodesIncrease; if( quantityOfNodes > kMaxNodes ) quantityOfNodes = kMaxNodes; updateQuantityLabel(); updateQuantityOfNodes(); }
void NodeChildrenMainScene::onDecrease(CCObject* pSender) { quantityOfNodes -= kNodesIncrease; if( quantityOfNodes < 0 ) quantityOfNodes = 0; updateQuantityLabel(); updateQuantityOfNodes(); }
void ParticleMainScene::doAutoTest() { isStating = false; statCount = 0; totalStatTime = 0.0f; minFrameRate = -1.0f; maxFrameRate = -1.0f; quantityParticles = autoTestParticleCounts[autoTestIndex]; updateQuantityLabel(); updateTitle(); createParticleSystem(); schedule(CC_SCHEDULE_SELECTOR(ParticleMainScene::beginStat), DELAY_TIME); schedule(CC_SCHEDULE_SELECTOR(ParticleMainScene::endStat), DELAY_TIME + STAT_TIME); }
//////////////////////////////////////////////////////// // // NodeChildrenMainScene // //////////////////////////////////////////////////////// void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) { //srand(time()); CCSize s = CCDirector::sharedDirector()->getWinSize(); // Title CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(ccp(s.width/2, s.height-32)); label->setColor(ccc3(255,255,40)); // Subtitle std::string strSubTitle = subtitle(); if(strSubTitle.length()) { CCLabelTTF *l = CCLabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } lastRenderedCount = 0; currentQuantityOfNodes = 0; quantityOfNodes = nNodes; CCMenuItemFont::setFontSize(65); CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(NodeChildrenMainScene::onDecrease)); decrease->setColor(ccc3(0,200,20)); CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(NodeChildrenMainScene::onIncrease)); increase->setColor(ccc3(0,200,20)); CCMenu *menu = CCMenu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(ccp(s.width/2, s.height/2+15)); addChild(menu, 1); CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(ccc3(0,200,20)); infoLabel->setPosition(ccp(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); NodeChildrenMenuLayer* pMenu = new NodeChildrenMenuLayer(true, TEST_COUNT, s_nCurCase); addChild(pMenu); pMenu->release(); updateQuantityLabel(); updateQuantityOfNodes(); }
void NodeChildrenMainScene::onEnterTransitionDidFinish() { auto director = Director::getInstance(); auto sched = director->getScheduler(); if (this->isAutoTesting()) { // Update the quantity of nodes if is auto testing. quantityOfNodes = autoTestNodesNums[autoTestIndex]; updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); Profile::getInstance()->testCaseBegin("NodeChildrenTest", genStrVector("Type", "NodeCount", nullptr), genStrVector("Avg", "Min", "Max", nullptr)); } CC_PROFILER_PURGE_ALL(); sched->schedule(CC_SCHEDULE_SELECTOR(NodeChildrenMainScene::dumpProfilerInfo), this, 2, false); }
//////////////////////////////////////////////////////// // // PerformanceEventDispatcherScene // //////////////////////////////////////////////////////// void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNodes) { _type = 0; srand((unsigned)time(nullptr)); auto s = Director::getInstance()->getWinSize(); // Title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1, TAG_TITLE); label->setPosition(Vec2(s.width/2, s.height-50)); // Subtitle std::string strSubTitle = subtitle(); if(strSubTitle.length()) { auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); addChild(l, 1, TAG_SUBTITLE); l->setPosition(Vec2(s.width/2, s.height-80)); } _lastRenderedCount = 0; _currentQuantityOfNodes = 0; _quantityOfNodes = nNodes; MenuItemFont::setFontSize(65); auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { _quantityOfNodes -= kNodesIncrease; if( _quantityOfNodes < 0 ) _quantityOfNodes = 0; updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); srand(0); }); decrease->setColor(Color3B(0,200,20)); _decrease = decrease; auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { _quantityOfNodes += kNodesIncrease; if( _quantityOfNodes > kMaxNodes ) _quantityOfNodes = kMaxNodes; updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); srand(0); }); increase->setColor(Color3B(0,200,20)); _increase = increase; auto menu = Menu::create(decrease, increase, nullptr); menu->alignItemsHorizontally(); menu->setPosition(Vec2(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = Label::createWithTTF("0 listeners", "fonts/Marker Felt.ttf", 30); infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Vec2(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); auto menuLayer = new (std::nothrow) EventDispatcherBasicLayer(true, MAX_LAYER, g_curCase); addChild(menuLayer); menuLayer->release(); int oldFontSize = MenuItemFont::getFontSize(); MenuItemFont::setFontSize(24); Vector<cocos2d::MenuItem *> toggleItems; generateTestFunctions(); CCASSERT(!_testFunctions.empty(), "Should not be empty after generate test functions"); for (const auto& f : _testFunctions) { toggleItems.pushBack(MenuItemFont::create(f.name)); } auto reset = [this](){ // Removes all nodes for (auto& node : _nodes) { node->removeFromParent(); } _nodes.clear(); // Removes all fixed listeners for (auto& listener : _fixedPriorityListeners) { Director::getInstance()->getEventDispatcher()->removeEventListener(listener); } this->_lastRenderedCount = 0; }; auto toggle = MenuItemToggle::createWithCallback([=](Ref* sender){ auto toggle = static_cast<MenuItemToggle*>(sender); this->_type = toggle->getSelectedIndex(); auto label = static_cast<Label*>(this->getChildByTag(TAG_SUBTITLE)); label->setString(StringUtils::format("Test '%s', See console", this->_testFunctions[this->_type].name)); this->updateProfilerName(); reset(); }, toggleItems); toggle->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); toggle->setPosition(VisibleRect::left()); _toggle = toggle; auto start = MenuItemFont::create("start", [this](Ref* sender){ auto director = Director::getInstance(); auto sched = director->getScheduler(); CC_PROFILER_PURGE_ALL(); sched->schedule(CC_SCHEDULE_SELECTOR(PerformanceEventDispatcherScene::dumpProfilerInfo), this, 2, false); this->unscheduleUpdate(); this->scheduleUpdate(); this->_startItem->setEnabled(false); this->_stopItem->setEnabled(true); this->_toggle->setEnabled(false); this->_increase->setEnabled(false); this->_decrease->setEnabled(false); }); start->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); start->setPosition(VisibleRect::right() + Vec2(0, 40)); _startItem = start; auto stop = MenuItemFont::create("stop", [=](Ref* sender){ auto director = Director::getInstance(); auto sched = director->getScheduler(); sched->unschedule(CC_SCHEDULE_SELECTOR(PerformanceEventDispatcherScene::dumpProfilerInfo), this); this->unscheduleUpdate(); this->_startItem->setEnabled(true); this->_stopItem->setEnabled(false); this->_toggle->setEnabled(true); this->_increase->setEnabled(true); this->_decrease->setEnabled(true); reset(); }); stop->setEnabled(false); stop->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT); stop->setPosition(VisibleRect::right() + Vec2(0, -40)); _stopItem = stop; auto menu2 = Menu::create(toggle, start, stop, nullptr); menu2->setPosition(Vec2::ZERO); addChild(menu2); MenuItemFont::setFontSize(oldFontSize); updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); }
//////////////////////////////////////////////////////// // // NodeChildrenMainScene // //////////////////////////////////////////////////////// void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) { //srand(time()); auto s = Director::getInstance()->getWinSize(); // Title auto label = LabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 1); label->setPosition(Point(s.width/2, s.height-50)); // Subtitle std::string strSubTitle = subtitle(); if(strSubTitle.length()) { auto l = LabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(Point(s.width/2, s.height-80)); } lastRenderedCount = 0; currentQuantityOfNodes = 0; quantityOfNodes = nNodes; MenuItemFont::setFontSize(65); auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { quantityOfNodes -= kNodesIncrease; if( quantityOfNodes < 0 ) quantityOfNodes = 0; updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); srand(0); }); decrease->setColor(Color3B(0,200,20)); auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { quantityOfNodes += kNodesIncrease; if( quantityOfNodes > kMaxNodes ) quantityOfNodes = kMaxNodes; updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); srand(0); }); increase->setColor(Color3B(0,200,20)); auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(Point(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Point(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); auto menuLayer = new NodeChildrenMenuLayer(true, MAX_LAYER, g_curCase); addChild(menuLayer); menuLayer->release(); updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); srand(0); }
//////////////////////////////////////////////////////// // // ParticleMainScene // //////////////////////////////////////////////////////// void ParticleMainScene::initWithSubTest(int asubtest, int particles) { //srandom(0); subtestNumber = asubtest; CCSize s = CCDirector::sharedDirector()->getWinSize(); lastRenderedCount = 0; quantityParticles = particles; CCMenuItemFont::setFontSize(65); CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(ParticleMainScene::onDecrease)); decrease->setColor(ccc3(0,200,20)); CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(ParticleMainScene::onIncrease)); increase->setColor(ccc3(0,200,20)); CCMenu *menu = CCMenu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(ccp(s.width/2, s.height/2+15)); addChild(menu, 1); CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(ccc3(0,200,20)); infoLabel->setPosition(ccp(s.width/2, s.height - 90)); addChild(infoLabel, 1, kTagInfoLayer); // particles on stage CCLabelAtlas *labelAtlas = CCLabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 0, kTagLabelAtlas); labelAtlas->setPosition(ccp(s.width-66,50)); // Next Prev Test ParticleMenuLayer* pMenu = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx); addChild(pMenu, 1, kTagMenuLayer); pMenu->release(); // Sub Tests CCMenuItemFont::setFontSize(40); CCMenu* pSubMenu = CCMenu::create(); for (int i = 1; i <= 6; ++i) { char str[10] = {0}; sprintf(str, "%d ", i); CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(ParticleMainScene::testNCallback)); itemFont->setTag(i); pSubMenu->addChild(itemFont, 10); if (i <= 3) { itemFont->setColor(ccc3(200,20,20)); } else { itemFont->setColor(ccc3(0,200,20)); } } pSubMenu->alignItemsHorizontally(); pSubMenu->setPosition(ccp(s.width/2, 80)); addChild(pSubMenu, 2); CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(ccp(s.width/2, s.height-32)); label->setColor(ccc3(255,255,40)); updateQuantityLabel(); createParticleSystem(); schedule(schedule_selector(ParticleMainScene::step)); }
void ParticleMainScene::initWithSubTest(int asubtest, int particles) { //srandom(0); isStating = false; subtestNumber = asubtest; auto s = Director::getInstance()->getWinSize(); lastRenderedCount = 0; quantityParticles = particles; MenuItemFont::setFontSize(65); auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { quantityParticles -= kNodesIncrease; if( quantityParticles < 0 ) quantityParticles = 0; updateQuantityLabel(); createParticleSystem(); }); decrease->setColor(Color3B(0,200,20)); auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { quantityParticles += kNodesIncrease; if( quantityParticles > kMaxParticles ) quantityParticles = kMaxParticles; updateQuantityLabel(); createParticleSystem(); }); increase->setColor(Color3B(0,200,20)); auto menu = Menu::create(decrease, increase, nullptr); menu->alignItemsHorizontally(); menu->setPosition(Vec2(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30); infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Vec2(s.width/2, s.height - 90)); addChild(infoLabel, 1, kTagInfoLayer); // particles on stage auto labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 0, kTagLabelAtlas); labelAtlas->setPosition(Vec2(s.width-66,50)); // Sub Tests MenuItemFont::setFontSize(40); auto pSubMenu = Menu::create(); for (int i = 1; i <= MAX_SUB_TEST_NUM; ++i) { char str[10] = {0}; sprintf(str, "%d ", i); auto itemFont = MenuItemFont::create(str, CC_CALLBACK_1(ParticleMainScene::testNCallback, this)); itemFont->setTag(i); pSubMenu->addChild(itemFont, 10); if (i <= 3) { itemFont->setColor(Color3B(200,20,20)); } else { itemFont->setColor(Color3B(0,200,20)); } } pSubMenu->alignItemsHorizontally(); pSubMenu->setPosition(Vec2(s.width/2, 80)); addChild(pSubMenu, 2); auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1, kTagTitle); label->setPosition(Vec2(s.width/2, s.height-50)); updateQuantityLabel(); createParticleSystem(); schedule(CC_SCHEDULE_SELECTOR(ParticleMainScene::step)); }
//////////////////////////////////////////////////////// // // ParticleMainScene // //////////////////////////////////////////////////////// void ParticleMainScene::initWithSubTest(int asubtest, int particles) { //srandom(0); subtestNumber = asubtest; auto s = Director::getInstance()->getWinSize(); lastRenderedCount = 0; quantityParticles = particles; MenuItemFont::setFontSize(65); auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { quantityParticles -= kNodesIncrease; if( quantityParticles < 0 ) quantityParticles = 0; updateQuantityLabel(); createParticleSystem(); }); decrease->setColor(Color3B(0,200,20)); auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { quantityParticles += kNodesIncrease; if( quantityParticles > kMaxParticles ) quantityParticles = kMaxParticles; updateQuantityLabel(); createParticleSystem(); }); increase->setColor(Color3B(0,200,20)); auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(Point(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Point(s.width/2, s.height - 90)); addChild(infoLabel, 1, kTagInfoLayer); // particles on stage auto labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 0, kTagLabelAtlas); labelAtlas->setPosition(Point(s.width-66,50)); // Next Prev Test auto menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx); addChild(menuLayer, 1, kTagMenuLayer); menuLayer->release(); // Sub Tests MenuItemFont::setFontSize(40); auto pSubMenu = Menu::create(); for (int i = 1; i <= 6; ++i) { char str[10] = {0}; sprintf(str, "%d ", i); auto itemFont = MenuItemFont::create(str, CC_CALLBACK_1(ParticleMainScene::testNCallback, this)); itemFont->setTag(i); pSubMenu->addChild(itemFont, 10); if (i <= 3) { itemFont->setColor(Color3B(200,20,20)); } else { itemFont->setColor(Color3B(0,200,20)); } } pSubMenu->alignItemsHorizontally(); pSubMenu->setPosition(Point(s.width/2, 80)); addChild(pSubMenu, 2); auto label = LabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 1); label->setPosition(Point(s.width/2, s.height-50)); updateQuantityLabel(); createParticleSystem(); schedule(schedule_selector(ParticleMainScene::step)); }
//////////////////////////////////////////////////////// // // PerformanceContainerScene // //////////////////////////////////////////////////////// void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) { _type = 0; //srand(time()); auto s = Director::getInstance()->getWinSize(); // Title auto label = LabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 1, TAG_TITLE); label->setPosition(Point(s.width/2, s.height-50)); // Subtitle std::string strSubTitle = subtitle(); if(strSubTitle.length()) { auto l = LabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); addChild(l, 1, TAG_SUBTITLE); l->setPosition(Point(s.width/2, s.height-80)); } lastRenderedCount = 0; currentQuantityOfNodes = 0; quantityOfNodes = nNodes; MenuItemFont::setFontSize(65); auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { quantityOfNodes -= kNodesIncrease; if( quantityOfNodes < 0 ) quantityOfNodes = 0; updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); srand(0); }); decrease->setColor(Color3B(0,200,20)); _decrease = decrease; auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { quantityOfNodes += kNodesIncrease; if( quantityOfNodes > kMaxNodes ) quantityOfNodes = kMaxNodes; updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); srand(0); }); increase->setColor(Color3B(0,200,20)); _increase = increase; auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(Point(s.width/2, s.height/2+15)); addChild(menu, 1); auto infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Point(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); auto menuLayer = new ContainerBasicLayer(true, MAX_LAYER, g_curCase); addChild(menuLayer); menuLayer->release(); printf("Size of Node: %lu\n", sizeof(Node)); int oldFontSize = MenuItemFont::getFontSize(); MenuItemFont::setFontSize(24); Vector<cocos2d::MenuItem *> toggleItems; generateTestFunctions(); CCASSERT(!_testFunctions.empty(), "Should not be empty after generate test functions"); for (const auto& f : _testFunctions) { toggleItems.pushBack(MenuItemFont::create(f.name)); } auto toggle = MenuItemToggle::createWithCallback([this](Ref* sender){ auto toggle = static_cast<MenuItemToggle*>(sender); this->_type = toggle->getSelectedIndex(); auto label = static_cast<LabelTTF*>(this->getChildByTag(TAG_SUBTITLE)); label->setString(StringUtils::format("Test '%s', See console", this->_testFunctions[this->_type].name)); this->updateProfilerName(); }, toggleItems); toggle->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); toggle->setPosition(VisibleRect::left()); _toggle = toggle; auto start = MenuItemFont::create("start", [this](Ref* sender){ auto director = Director::getInstance(); auto sched = director->getScheduler(); CC_PROFILER_PURGE_ALL(); sched->schedule(schedule_selector(PerformanceContainerScene::dumpProfilerInfo), this, 2, false); this->unscheduleUpdate(); this->scheduleUpdate(); this->_startItem->setEnabled(false); this->_stopItem->setEnabled(true); this->_toggle->setEnabled(false); this->_increase->setEnabled(false); this->_decrease->setEnabled(false); }); start->setAnchorPoint(Point::ANCHOR_MIDDLE_RIGHT); start->setPosition(VisibleRect::right() + Point(0, 40)); _startItem = start; auto stop = MenuItemFont::create("stop", [this](Ref* sender){ auto director = Director::getInstance(); auto sched = director->getScheduler(); sched->unschedule(schedule_selector(PerformanceContainerScene::dumpProfilerInfo), this); this->unscheduleUpdate(); this->_startItem->setEnabled(true); this->_stopItem->setEnabled(false); this->_toggle->setEnabled(true); this->_increase->setEnabled(true); this->_decrease->setEnabled(true); }); stop->setEnabled(false); stop->setAnchorPoint(Point::ANCHOR_MIDDLE_RIGHT); stop->setPosition(VisibleRect::right() + Point(0, -40)); _stopItem = stop; auto menu2 = Menu::create(toggle, start, stop, NULL); menu2->setPosition(Point::ZERO); addChild(menu2); MenuItemFont::setFontSize(oldFontSize); updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); }