//------------------------------------------------------------------ // // SchedulerTestLayer // //------------------------------------------------------------------ void SchedulerTestLayer::onEnter() { CCLayer::onEnter(); CGSize s = CCDirector::sharedDirector()->getWinSize(); CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 32); addChild(label); label->setPosition(ccp(s.width/2, s.height-50)); std::string subTitle = subtitle(); if(! subTitle.empty()) { CCLabel* l = CCLabel::labelWithString(subTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(SchedulerTestLayer::backCallback)); CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(SchedulerTestLayer::restartCallback) ); CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(SchedulerTestLayer::nextCallback) ); CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition(CGPointZero); item1->setPosition(ccp( s.width/2 - 100,30)); item2->setPosition(ccp( s.width/2, 30)); item3->setPosition(ccp( s.width/2 + 100,30)); addChild(menu, 1); }
//------------------------------------------------------------------ // // TextureDemo // //------------------------------------------------------------------ void TextureDemo::onEnter() { CCLayer::onEnter(); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 26); addChild(label, 1, kTagLabel); label->setPosition(ccp(s.width/2, s.height-50)); 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)); } CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TextureDemo::backCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TextureDemo::restartCallback) ); CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TextureDemo::nextCallback) ); CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp( s.width/2 - 100,30)); item2->setPosition(ccp( s.width/2, 30)); item3->setPosition(ccp( s.width/2 + 100,30)); addChild(menu, 1); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); }
void BaseTest::onEnter() { Layer::onEnter(); // add title and subtitle std::string str = title(); const char * pTitle = str.c_str(); LabelTTF* label = LabelTTF::create(pTitle, "Arial", 32); addChild(label, 9999); label->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 30) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { LabelTTF* l = LabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 9999); l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 60) ); } // add menu // CC_CALLBACK_1 == std::bind( function_ptr, instance, std::placeholders::_1, ...) MenuItemImage *item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(BaseTest::backCallback, this) ); MenuItemImage *item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(BaseTest::restartCallback, this) ); MenuItemImage *item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(BaseTest::nextCallback, this) ); Menu *menu = Menu::create(item1, item2, item3, NULL); menu->setPosition(Point::ZERO); item1->setPosition(Point(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); item2->setPosition(Point(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); item3->setPosition(Point(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); addChild(menu, 9999); }
//////////////////////////////////// // // HiResDemo // /////////////////////////////////// void HiResDemo::onEnter() { CCLayer::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); label->setPosition(ccp(s.width/2, s.height-50)); addChild(label, 1); std::string sSubTitle = subtitle(); if (sSubTitle.length()) { CCLabelTTF *subLabel = CCLabelTTF::labelWithString(sSubTitle.c_str(), "Thonburi", 16); subLabel->setPosition(ccp(s.width/2, s.height-80)); addChild(subLabel, 1); } CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(HiResDemo::backCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(HiResDemo::restartCallback) ); CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(HiResDemo::nextCallback) ); CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition( CCPointMake( s.width/2 - 100,30) ); item2->setPosition( CCPointMake( s.width/2, 30) ); item3->setPosition( CCPointMake( s.width/2 + 100,30) ); addChild(menu, 1); }
void TestCase::onEnter() { Scene::onEnter(); if (_testSuite == nullptr) { setTestSuite(TestController::getInstance()->getCurrTestSuite()); } if (_testSuite) { _titleLabel->setString(StringUtils::format("%d", static_cast<int>(_testSuite->getCurrTestIndex() + 1)) + ":" + title()); } else { _titleLabel->setString(title()); } _subtitleLabel->setString(subtitle()); if (_testSuite && _testSuite->getChildTestCount() < 2) { _priorTestItem->setVisible(false); _nextTestItem->setVisible(false); _restartTestItem->setVisible(false); } }
//------------------------------------------------------------------ // // SchedulerTestLayer // //------------------------------------------------------------------ void SchedulerTestLayer::onEnter() { CCLayer::onEnter(); CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32); addChild(label); label->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-50)); std::string subTitle = subtitle(); if(! subTitle.empty()) { CCLabelTTF* l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-80)); } CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(SchedulerTestLayer::backCallback)); CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(SchedulerTestLayer::restartCallback) ); CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(SchedulerTestLayer::nextCallback) ); CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); addChild(menu, 1); }
///--------------------------------------- // // DirectorTest // ///--------------------------------------- bool DirectorTest::init() { bool bRet = false; do { CC_BREAK_IF(! CCLayer::init()); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 26); addChild(label, 1); label->setPosition(ccp(s.width/2, s.height-50)); std::string sSubtitle = subtitle(); if (sSubtitle.length()) { CCLabelTTF *l = CCLabelTTF::labelWithString(sSubtitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(DirectorTest::backCallback)); CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(DirectorTest::restartCallback)); CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(DirectorTest::nextCallback)); CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp( s.width/2 - 100,30)); item2->setPosition(ccp( s.width/2, 30)); item3->setPosition(ccp( s.width/2 + 100,30)); bRet = true; } while (0); return bRet; }
void PerformanceCallbackScene::onEnter() { Scene::onEnter(); CC_PROFILER_PURGE_ALL(); auto s = Director::getInstance()->getWinSize(); auto menuLayer = new (std::nothrow) CallbackBasicLayer(true, MAX_LAYER, g_curCase); addChild(menuLayer); menuLayer->release(); // Title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1); 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); l->setPosition(Vec2(s.width/2, s.height-80)); } getScheduler()->schedule(CC_SCHEDULE_SELECTOR(PerformanceCallbackScene::onUpdate), this, 0.0f, false); getScheduler()->schedule(CC_SCHEDULE_SELECTOR(PerformanceCallbackScene::dumpProfilerInfo), this, 2, false); }
void AtlasDemo::onEnter() { CCLayer::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28); addChild(label, 1); label->setPosition( ccp(s.width/2, s.height-50) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition( ccp(s.width/2, s.height-80) ); } CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(AtlasDemo::backCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(AtlasDemo::restartCallback) ); CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(AtlasDemo::nextCallback) ); CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));; addChild(menu, 1); }
void TextureAtlasEncryptionDemo::onEnter() { CCLayer::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28); label->setPosition( ccp(s.width/2, s.height * 0.75f) ); this->addChild(label, 1); std::string strSubtitle = subtitle(); if(strSubtitle.empty() == false) { CCLabelTTF* subLabel = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); subLabel->setPosition( ccp(s.width/2, s.height-80) ); this->addChild(subLabel, 1); } // Load the non-encrypted atlas CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Images/nonencryptedAtlas.plist", "Images/nonencryptedAtlas.pvr.ccz"); // Create a sprite from the non-encrypted atlas CCSprite *nonencryptedSprite = CCSprite::createWithSpriteFrameName("Icon.png"); nonencryptedSprite->setPosition(ccp(s.width * 0.25f, s.height * 0.5f)); this->addChild(nonencryptedSprite); CCLabelTTF* nonencryptedSpriteLabel = CCLabelTTF::create("non-encrypted", "Arial", 28); nonencryptedSpriteLabel->setPosition(ccp(s.width * 0.25f, nonencryptedSprite->boundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2)); this->addChild(nonencryptedSpriteLabel, 1); // Load the encrypted atlas // 1) Set the encryption keys or step 2 will fail // In this case the encryption key 0xaaaaaaaabbbbbbbbccccccccdddddddd is // split into four parts. See the header docs for more information. ZipUtils::ccSetPvrEncryptionKeyPart(0, 0xaaaaaaaa); ZipUtils::ccSetPvrEncryptionKeyPart(1, 0xbbbbbbbb); ZipUtils::ccSetPvrEncryptionKeyPart(2, 0xcccccccc); ZipUtils::ccSetPvrEncryptionKeyPart(3, 0xdddddddd); // Alternatively, you can call the function that accepts the key in a single // function call. // This is slightly less secure because the entire key is more easily // found in the compiled source. See the header docs for more information. // ZipUtils::ccSetPvrEncryptionKey(0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xdddddddd); // 2) Load the encrypted atlas CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Images/encryptedAtlas.plist", "Images/encryptedAtlas.pvr.ccz"); // 3) Create a sprite from the encrypted atlas CCSprite *encryptedSprite = CCSprite::createWithSpriteFrameName("powered.png"); encryptedSprite->setPosition(ccp(s.width * 0.75f, s.height * 0.5f)); this->addChild(encryptedSprite); CCLabelTTF* encryptedSpriteLabel = CCLabelTTF::create("encrypted", "Arial", 28); encryptedSpriteLabel->setPosition(ccp(s.width * 0.75f, encryptedSprite->boundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2)); this->addChild(encryptedSpriteLabel, 1); }
void EffectAdvanceTextLayer::onEnter(void) { CCLayer::onEnter(); float x,y; CGSize size = CCDirector::sharedDirector()->getWinSize(); x = size.width; y = size.height; CCSprite *bg = CCSprite::spriteWithFile("Images/background3.png"); addChild(bg, 0, kTagBackground); bg->setPosition( ccp(x/2,y/2) ); CCSprite* grossini = CCSprite::spriteWithFile("Images/grossinis_sister2.png"); bg->addChild(grossini, 1, kTagSprite1); grossini->setPosition( ccp(x/3.0f,200) ); CCActionInterval* sc = CCScaleBy::actionWithDuration(2, 5); CCActionInterval* sc_back = sc->reverse(); grossini->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc, sc_back, NULL)) ) ); CCSprite* tamara = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); bg->addChild(tamara, 1, kTagSprite2); tamara->setPosition( ccp(2*x/3.0f,200) ); CCActionInterval* sc2 = CCScaleBy::actionWithDuration(2, 5); CCActionInterval* sc2_back = sc2->reverse(); tamara->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc2, sc2_back, NULL)) ) ); CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Marker Felt", 28); label->setPosition( ccp(x/2,y-80) ); addChild(label); label->setTag( kTagLabel ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 101); l->setPosition( ccp(size.width/2, size.height-80) ); } CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) ); CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) ); CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CGPointZero ); item1->setPosition( ccp( size.width/2 - 100,30) ); item2->setPosition( ccp( size.width/2, 30) ); item3->setPosition( ccp( size.width/2 + 100,30) ); addChild(menu, 1); }
void GText::resetStyle(STYLE newStyle) { _style = newStyle; _default(); if (flagSetted(TITLE)) { title(); } else if (flagSetted(SUBTITLE)) { subtitle(); } else { flagSetted(SELECTED) ? select() : unselect(); flagSetted(VALIDATED) ? validate() : unvalidate(); } }
void EffectAdvanceTextLayer::onEnter(void) { CCLayer::onEnter(); CCSprite *bg = CCSprite::create("Images/background3.png"); addChild(bg, 0, kTagBackground); bg->setPosition( VisibleRect::center() ); CCSprite* grossini = CCSprite::create("Images/grossinis_sister2.png"); bg->addChild(grossini, 1, kTagSprite1); grossini->setPosition( ccp(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) ); CCActionInterval* sc = CCScaleBy::create(2, 5); CCActionInterval* sc_back = sc->reverse(); grossini->runAction( CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(sc, sc_back, NULL)) ) ); CCSprite* tamara = CCSprite::create("Images/grossinis_sister1.png"); bg->addChild(tamara, 1, kTagSprite2); tamara->setPosition( ccp(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) ); CCActionInterval* sc2 = CCScaleBy::create(2, 5); CCActionInterval* sc2_back = sc2->reverse(); tamara->runAction( CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(sc2, sc2_back, NULL)) ) ); CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Marker Felt", 28); label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) ); addChild(label); label->setTag( kTagLabel ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 101); l->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) ); } CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) ); CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) ); CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); addChild(menu, 1); }
void VideoWindow::openSubtitleFile() { QString filename = QFileDialog::getOpenFileName(this, tr("Select Subtitle File")); if (filename.isEmpty()) { return; } QHash<QByteArray, QVariant> properties; properties.insert("type", "file"); properties.insert("name", filename); int id = 0; Phonon::SubtitleDescription subtitle(id, properties); _mediaController->setCurrentSubtitle(subtitle); }
//////////////////////////////////////////////////////// // // 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 TestCase::onEnter() { Scene::onEnter(); _titleLabel->setString(title()); _subtitleLabel->setString(subtitle()); if (_testSuite == nullptr) { setTestSuite(TestController::getInstance()->getCurrTestSuite()); } if (_testSuite && _testSuite->getChildTestCount() < 2) { _priorTestItem->setVisible(false); _nextTestItem->setVisible(false); _restartTestItem->setVisible(false); } }
void PrettyPrinterDemo::onEnter() { CCLayer::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28); label->setPosition( ccp(s.width/2, s.height * 4/5) ); this->addChild(label, 1); std::string strSubtitle = subtitle(); if(strSubtitle.empty() == false) { CCLabelTTF* subLabel = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); subLabel->setPosition( ccp(s.width/2, s.height * 3/5) ); this->addChild(subLabel, 1); } // Test code CCPrettyPrinter vistor; // print dictionary CCDictionary* pDict = CCDictionary::createWithContentsOfFile("animations/animations.plist"); pDict->acceptVisitor(vistor); CCLog("%s", vistor.getResult().c_str()); CCLog("-------------------------------"); CCSet myset; for (int i = 0; i < 30; ++i) { myset.addObject(CCString::createWithFormat("str: %d", i)); } vistor.clear(); myset.acceptVisitor(vistor); CCLog("%s", vistor.getResult().c_str()); CCLog("-------------------------------"); vistor.clear(); addSprite(); pDict = CCTextureCache::sharedTextureCache()->snapshotTextures(); pDict->acceptVisitor(vistor); CCLog("%s", vistor.getResult().c_str()); }
void ScenarioMenuLayer::onEnter() { PerformBasicLayer::onEnter(); auto s = Director::getInstance()->getWinSize(); // Title auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); addChild(label, 1); 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); l->setPosition(Vec2(s.width/2, s.height-80)); } performTests(); }
bool TestCase::init() { if (Scene::init()) { // add title and subtitle TTFConfig ttfConfig("fonts/arial.ttf", 26); _titleLabel = Label::createWithTTF(ttfConfig, title()); addChild(_titleLabel, 9999); _titleLabel->setPosition(VisibleRect::center().x, VisibleRect::top().y - 30); ttfConfig.fontSize = 16; _subtitleLabel = Label::createWithTTF(ttfConfig, subtitle()); _subtitleLabel->setMaxLineWidth(VisibleRect::getVisibleRect().size.width); addChild(_subtitleLabel, 9999); _subtitleLabel->setPosition(VisibleRect::center().x, VisibleRect::top().y - 60); _priorTestItem = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(TestCase::priorTestCallback, this)); _restartTestItem = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(TestCase::restartTestCallback, this)); _nextTestItem = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(TestCase::nextTestCallback, this)); ttfConfig.fontSize = 20; auto backLabel = Label::createWithTTF(ttfConfig, "Back"); auto backItem = MenuItemLabel::create(backLabel, CC_CALLBACK_1(TestCase::onBackCallback, this)); auto menu = Menu::create(_priorTestItem, _restartTestItem, _nextTestItem, backItem, nullptr); menu->setPosition(Vec2::ZERO); _priorTestItem->setPosition(VisibleRect::center().x - _restartTestItem->getContentSize().width * 2, VisibleRect::bottom().y + _restartTestItem->getContentSize().height / 2); _restartTestItem->setPosition(VisibleRect::center().x, VisibleRect::bottom().y + _restartTestItem->getContentSize().height / 2); _nextTestItem->setPosition(VisibleRect::center().x + _restartTestItem->getContentSize().width * 2, VisibleRect::bottom().y + _restartTestItem->getContentSize().height / 2); backItem->setPosition(Vec2(VisibleRect::right().x - 50, VisibleRect::bottom().y + 25)); addChild(menu, 9999); return true; } return false; }
void BaseTest::onEnter() { Layer::onEnter(); AppDelegate* app = (AppDelegate *)Application::getInstance(); app->setCurrentTest(this); // add title and subtitle std::string str = title(); const char * pTitle = str.c_str(); TTFConfig ttfConfig("fonts/arial.ttf", 32); auto label = Label::createWithTTF(ttfConfig,pTitle); addChild(label, 9999); label->setPosition(VisibleRect::center().x, VisibleRect::top().y - 30); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { ttfConfig.fontFilePath = "fonts/Thonburi.ttf"; ttfConfig.fontSize = 16; auto l = Label::createWithTTF(ttfConfig,strSubtitle.c_str()); addChild(l, 9999); l->setPosition(VisibleRect::center().x, VisibleRect::top().y - 60); } // add menu // CC_CALLBACK_1 == std::bind( function_ptr, instance, std::placeholders::_1, ...) auto item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(BaseTest::backCallback, this) ); auto item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(BaseTest::restartCallback, this) ); auto item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(BaseTest::nextCallback, this) ); auto menu = Menu::create(item1, item2, item3, nullptr); menu->setPosition(Vec2::ZERO); item1->setPosition(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2); item2->setPosition(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2); item3->setPosition(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2); addChild(menu, 9999); }
void TextureMenuLayer::onEnter() { PerformBasicLayer::onEnter(); 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)); } performTests(); }
void TextureMenuLayer::onEnter() { PerformBasicLayer::onEnter(); auto s = Director::getInstance()->getWinSize(); // Title auto label = LabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(Point(s.width/2, s.height-32)); label->setColor(Color3B(255,255,40)); // 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)); } performTests(); }
// 毎フレーム update() の次に呼ばれる void Rule::draw() const { int t = System::FrameCount()*3; game1_m.draw(t % (1280 * 3) - 1280, 0, Alpha(50)); game2_m.draw((t+1280) % (1280 * 3) - 1280, 0, Alpha(50)); game3_m.draw((t + 2560) % (1280 * 3) - 1280, 0, Alpha(50)); for (int i = 0; i < 40; i++) { cir[i].draw(); } RoundRect(Rect(700, 700).setCenter(Window::Center()).movedBy(0, 0), 20).draw(Color(Palette::White, 180)).drawFrame(0.0, 3.0, Palette::Black); mainimage.drawAt(Window::Width() / 2, Window::Height() * 3 / 4 - 90); title(L"ルール!").drawCenter({ Window::Width() / 2, title.size }, Color(255, 0, 0)); text(L"これはガベージコレクションをするゲームです").drawCenter({ Window::Width() / 2, (title.size + text.size) * 2 }, Color(0, 0, 0)); subtitle(L"やり方").drawCenter({ Window::Width() / 2, (title.size + text.size + subtitle.size) * 2 }, Color(0, 0, 0)); button_m.draw(); clickable::Button::drawEffect(); Cir::drawEffect(); }
//////////////////////////////////////////////////////// // // 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(); }
void SessionChildItem::receiveMessage(IrcMessage* message) { if (m_usermodel) m_usermodel->processMessage(message); if (message->type() == IrcMessage::Numeric) { IrcNumericMessage* numeric = static_cast<IrcNumericMessage*>(message); switch (numeric->code()) { case Irc::RPL_NAMREPLY: if (m_sent.contains(IrcCommand::Names)) return; break; case Irc::RPL_ENDOFNAMES: if (m_sent.contains(IrcCommand::Names)) { emit namesReceived(m_usermodel->users()); m_sent.remove(IrcCommand::Names); return; } break; case Irc::RPL_TOPIC: if (isChannel()) { setSubtitle(message->parameters().value(2)); setDescription(IrcUtil::messageToHtml(subtitle())); } break; case Irc::RPL_WHOISUSER: if (!isChannel()) { setSubtitle(message->parameters().value(5)); setDescription(IrcUtil::messageToHtml(subtitle())); } if (m_sent.contains(IrcCommand::Whois)) { m_whois.append(tr("Ident: %1").arg(message->parameters().value(2))); m_whois.append(tr("Host: %1").arg(message->parameters().value(3))); m_whois.append(tr("Name: %1").arg(message->parameters().value(5))); return; } break; case Irc::RPL_WHOISSERVER: if (m_sent.contains(IrcCommand::Whois)) { m_whois.append(tr("Server: %1 (%2)").arg(message->parameters().value(2), message->parameters().value(3))); return; } break; case Irc::RPL_WHOISOPERATOR: if (m_sent.contains(IrcCommand::Whois)) { m_whois.append(tr("IRC operator")); return; } break; case Irc::RPL_WHOISACCOUNT: if (m_sent.contains(IrcCommand::Whois)) { m_whois.append(tr("Logged in as: %1").arg(message->parameters().value(2))); return; } break; case Irc::RPL_WHOISREGNICK: if (m_sent.contains(IrcCommand::Whois)) { m_whois.append(tr("Registered nick")); return; } break; case Irc::RPL_WHOISSECURE: if (m_sent.contains(IrcCommand::Whois)) { m_whois.append(tr("Secure connection")); return; } break; case Irc::RPL_WHOISIDLE: if (m_sent.contains(IrcCommand::Whois)) { QDateTime signon = QDateTime::fromTime_t(message->parameters().value(3).toInt()); QTime idle = QTime().addSecs(message->parameters().value(2).toInt()); m_whois.append(tr("Connected: %1").arg(signon.toString())); m_whois.append(tr("Idle: %1").arg(idle.toString())); return; } break; case Irc::RPL_WHOISCHANNELS: if (m_sent.contains(IrcCommand::Whois)) { m_whois.append(tr("Channels: %1").arg(message->parameters().value(2))); return; } break; case Irc::RPL_WHOISHOST: case Irc::RPL_WHOISMODES: if (m_sent.contains(IrcCommand::Whois)) { return; } break; case Irc::RPL_ENDOFWHOIS: if (m_sent.contains(IrcCommand::Whois)) { emit whoisReceived(m_whois); m_sent.remove(IrcCommand::Whois); m_whois.clear(); } case Irc::RPL_WHOISHELPOP: case Irc::RPL_WHOISSPECIAL: return; default: break; } } if (message->type() == IrcMessage::Private) { IrcPrivateMessage* privMsg = static_cast<IrcPrivateMessage*>(message); QString alertText; if (isChannel()) { if (privMsg->message().contains(m_parent->session()->nickName(), Qt::CaseInsensitive)) { setHighlighted(true); if (!isCurrent()) alertText = tr("%1 on %2:\n%3").arg(privMsg->sender().name()).arg(title()).arg(privMsg->message()); } } else { setHighlighted(true); if (!isCurrent()) alertText = tr("%1 in private:\n%2").arg(privMsg->sender().name()).arg(privMsg->message()); } if (!alertText.isEmpty()) emit alerted(alertText); if (!isCurrent()) setUnreadCount(unreadCount() + 1); } const QString formatted = messageFormatter()->formatMessage(message, m_usermodel); if (!formatted.isEmpty()) appendMessage(formatted); }
void ActionsDemo::onEnter() { CCLayer::onEnter(); // Example: // You can create a sprite using a Texture2D CCTexture2D *tex = new CCTexture2D(); UIImage* pImage = new UIImage(); std::string fullpath( CCFileUtils::fullPathFromRelativePath(s_pPathGrossini)); pImage->initWithContentsOfFile(fullpath); tex->initWithImage( pImage ); m_grossini = CCSprite::spriteWithTexture(tex); m_grossini->retain(); delete pImage; tex->release(); // Example: // Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too m_tamara = CCSprite::spriteWithFile(s_pPathSister1); m_tamara->retain(); m_kathia = CCSprite::spriteWithFile(s_pPathSister2); m_kathia->retain(); addChild(m_grossini, 1); addChild(m_tamara, 2); addChild(m_kathia, 3); CGSize s = CCDirector::sharedDirector()->getWinSize(); m_grossini->setPosition( CGPointMake(s.width/2, s.height/3)); m_tamara->setPosition( CGPointMake(s.width/2, 2*s.height/3)); m_kathia->setPosition( CGPointMake(s.width/2, s.height/2)); // add title and subtitle std::string str = title(); const char * pTitle = str.c_str(); CCLabelTTF* label = CCLabelTTF::labelWithString(pTitle, "Arial", 18); addChild(label, 1); label->setPosition( CGPointMake(s.width/2, s.height - 30) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 22); addChild(l, 1); l->setPosition( CGPointMake(s.width/2, s.height - 60) ); } // add menu CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ActionsDemo::backCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ActionsDemo::restartCallback) ); CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(ActionsDemo::nextCallback) ); CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CGPointZero ); item1->setPosition( CGPointMake( s.width/2 - 100,30) ); item2->setPosition( CGPointMake( s.width/2, 30) ); item3->setPosition( CGPointMake( s.width/2 + 100,30) ); addChild(menu, 1); }
//////////////////////////////////////////////////////// // // 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); }
void Ut_mdetailedlistitem::testSetSubtitle() { QString subtitle("Subtitle"); m_subject->setSubtitle(subtitle); QCOMPARE( m_subject->subtitle(), subtitle ); }
void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) { //srandom(0); subtestNumber = asubtest; _subTest = new SubTest; _subTest->initWithSubTest(asubtest, this); auto s = Director::getInstance()->getWinSize(); lastRenderedCount = 0; quantityNodes = 0; MenuItemFont::setFontSize(65); auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(SpriteMainScene::onDecrease, this)); decrease->setColor(Color3B(0,200,20)); auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(SpriteMainScene::onIncrease, this)); increase->setColor(Color3B(0,200,20)); auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(Point(s.width/2, s.height-65)); 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); // add menu auto menuLayer = new SpriteMenuLayer(true, TEST_COUNT, SpriteMainScene::_s_nSpriteCurCase); addChild(menuLayer, 1, kTagMenuLayer); menuLayer->release(); /** * auto test menu */ auto menuAutoTest = Menu::create(); menuAutoTest->setPosition( Point::ZERO ); MenuItemFont::setFontName("Arial"); MenuItemFont::setFontSize(24); MenuItemFont* autoTestItem = NULL; if (SpriteMainScene::_s_autoTest) { autoTestItem = MenuItemFont::create("Auto Test On",CC_CALLBACK_1(SpriteMainScene::onAutoTest, this)); } else { autoTestItem = MenuItemFont::create("Auto Test Off",CC_CALLBACK_1(SpriteMainScene::onAutoTest, this)); } autoTestItem->setTag(1); autoTestItem->setPosition(Point( s.width - 90, s.height / 2)); menuAutoTest->addChild(autoTestItem); addChild( menuAutoTest, 3, kTagAutoTestMenu ); // Sub Tests MenuItemFont::setFontSize(28); auto subMenu = Menu::create(); for (int i = 1; i <= 13; ++i) { char str[10] = {0}; sprintf(str, "%d ", i); auto itemFont = MenuItemFont::create(str, CC_CALLBACK_1(SpriteMainScene::testNCallback, this)); itemFont->setTag(i); subMenu->addChild(itemFont, 10); if( i<= 4) itemFont->setColor(Color3B(200,20,20)); else if(i <= 8) itemFont->setColor(Color3B(0,200,20)); else if( i<=12) itemFont->setColor(Color3B(0,20,200)); else itemFont->setColor(Color3B::GRAY); } subMenu->alignItemsHorizontally(); subMenu->setPosition(Point(s.width/2, 80)); addChild(subMenu, 2); // add title label auto label = LabelTTF::create(title(), "Arial", 40); addChild(label, 1); label->setPosition(Point(s.width/2, s.height-32)); label->setColor(Color3B(255,255,40)); // subtitle std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { auto l = LabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 9999); l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 60) ); } while(quantityNodes < nNodes) onIncrease(this); }
void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) { std::srand(0); _subtestNumber = asubtest; _subTest = new (std::nothrow) SubTest; _subTest->initWithSubTest(asubtest, this); auto s = Director::getInstance()->getWinSize(); _lastRenderedCount = 0; _quantityNodes = 0; MenuItemFont::setFontSize(65); auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(SpriteMainScene::onDecrease, this)); decrease->setColor(Color3B(0,200,20)); auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(SpriteMainScene::onIncrease, this)); increase->setColor(Color3B(0,200,20)); auto menu = Menu::create(decrease, increase, nullptr); menu->alignItemsHorizontally(); menu->setPosition(Vec2(s.width/2, s.height-65)); 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); /** * auto test menu */ auto menuAutoTest = Menu::create(); menuAutoTest->setPosition( Vec2::ZERO ); MenuItemFont::setFontName("fonts/arial.ttf"); MenuItemFont::setFontSize(24); // Sub Tests MenuItemFont::setFontSize(28); auto subMenu = Menu::create(); for (int i = 1; i <= 13; ++i) { char str[10] = {0}; sprintf(str, "%d ", i); auto itemFont = MenuItemFont::create(str, CC_CALLBACK_1(SpriteMainScene::testNCallback, this)); itemFont->setTag(i); subMenu->addChild(itemFont, 10); if( i<= 4) itemFont->setColor(Color3B(200,20,20)); else if(i <= 8) itemFont->setColor(Color3B(0,200,20)); else if( i<=12) itemFont->setColor(Color3B(0,20,200)); else itemFont->setColor(Color3B::GRAY); } subMenu->alignItemsHorizontally(); subMenu->setPosition(Vec2(s.width/2, 80)); addChild(subMenu, 2); // add title label auto label = Label::createWithTTF(title(), "fonts/arial.ttf", 32); addChild(label, 1, kTagTitle); label->setPosition(Vec2(s.width/2, s.height-50)); // subtitle std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { auto l = Label::createWithTTF(strSubtitle.c_str(), "fonts/Thonburi.ttf", 16); addChild(l, 9999); l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 60) ); } while(_quantityNodes < nNodes) onIncrease(this); }