// on "init" you need to initialize your instance bool StoreBScene::init() { ////////////////////////////// // 1. super init first if ( !CCLayerColor::initWithColor(ccc4(255,255,255,255))) { return false; } CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); CCLabelTTF* pLabelTitleTest = CCLabelTTF::create("Soomla Test Store", "GoodDog.otf", 34); pLabelTitleTest->setColor(ccc3(255,0,0)); pLabelTitleTest->setPosition(ccp(pLabelTitleTest->boundingBox().size.width/2 + origin.x + 20, visibleSize.height - 30 + origin.y)); this->addChild(pLabelTitleTest, 1); CCLabelTTF* pLabelTitle = CCLabelTTF::create("Virtual Currency Packs", "GoodDog.otf", 54); pLabelTitle->setColor(ccc3(0,0,0)); pLabelTitle->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height - 100 + origin.y)); this->addChild(pLabelTitle, 1); CCSprite* pSpriteMuffin = CCSprite::create("muffin.png"); pSpriteMuffin->setScale(0.5f); pSpriteMuffin->setPosition(ccp(origin.x + visibleSize.width - 90, visibleSize.height + origin.y - 50)); this->addChild(pSpriteMuffin, 0); pLabelBalance = CCLabelTTF::create("24", "GoodDog.otf", 34); pLabelBalance->setColor(ccc3(0,255,255)); pLabelBalance->setPosition(ccp(origin.x + visibleSize.width - 40, visibleSize.height + origin.y - 50)); this->addChild(pLabelBalance, 1); setCurrencyBalanceLabel(); GameMenuItem* backItem = GameMenuItem::itemWithLabel( CCSprite::create("back.png"), this, menu_selector(StoreBScene::menuBackCallback)); backItem->setPosition(ccp(origin.x + visibleSize.width/2 , 110)); // In Game Menu CCMenu* menu = CCMenu::create(backItem, NULL); createListViewItem(origin, menu, visibleSize, 0, "no_ads.png"); createListViewItem(origin, menu, visibleSize, 1, "muffins01.png"); createListViewItem(origin, menu, visibleSize, 2, "muffins02.png"); createListViewItem(origin, menu, visibleSize, 3, "muffins03.png"); createListViewItem(origin, menu, visibleSize, 4, "muffins04.png"); menu->setPosition(CCPointZero); this->addChild(menu); this->setKeypadEnabled(true); return true; }
// on "init" you need to initialize your instance bool StoreAScene::init() { cocos2dx_StoreController::storeOpening(); ////////////////////////////// // 1. super init first if ( !CCLayerColor::initWithColor(ccc4(255,255,255,255))) { return false; } CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); CCLabelTTF* pLabelTitleTest = CCLabelTTF::create("Soomla Test Store", "GoodDog.otf", 34); pLabelTitleTest->setColor(ccc3(255,0,0)); pLabelTitleTest->setPosition(ccp(pLabelTitleTest->boundingBox().size.width/2 + origin.x + 20, visibleSize.height - 30 + origin.y)); this->addChild(pLabelTitleTest, 1); CCLabelTTF* pLabelTitle = CCLabelTTF::create("Virtual Goods", "GoodDog.otf", 54); pLabelTitle->setColor(ccc3(0,0,0)); pLabelTitle->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height - 100 + origin.y)); this->addChild(pLabelTitle, 1); CCSprite* pSpriteMuffin = CCSprite::create("muffin.png"); pSpriteMuffin->setScale(0.5f); pSpriteMuffin->setPosition(ccp(origin.x + visibleSize.width - 90, visibleSize.height + origin.y - 50)); this->addChild(pSpriteMuffin, 0); pLabelBalance = CCLabelTTF::create("0", "GoodDog.otf", 34); pLabelBalance->setColor(ccc3(0,255,255)); pLabelBalance->setPosition(ccp(origin.x + visibleSize.width - 40, visibleSize.height + origin.y - 50)); this->addChild(pLabelBalance, 1); setCurrencyBalanceLabel(); GameMenuItem* getMoreItem = GameMenuItem::itemWithLabel( CCSprite::create("get_more.png"), this, menu_selector(StoreAScene::menuGetMoreCallback)); getMoreItem->setPosition(ccp(origin.x + visibleSize.width/2 + (getMoreItem->boundingBox().size.width /2) + 10, 110)); GameMenuItem* backItem = GameMenuItem::itemWithLabel( CCSprite::create("back.png"), this, menu_selector(StoreAScene::menuBackCallback)); backItem->setPosition(ccp(origin.x + visibleSize.width/2 - (backItem->boundingBox().size.width /2) - 10 , 110)); // In Game Menu CCMenu* menu = CCMenu::create(getMoreItem, backItem, NULL); createListViewItem(origin, menu, visibleSize, 0, "fruit_cake.png"); createListViewItem(origin, menu, visibleSize, 1, "pavlova.png"); createListViewItem(origin, menu, visibleSize, 2, "cream_cup.png"); createListViewItem(origin, menu, visibleSize, 3, "chocolate_cake.png"); menu->setPosition(CCPointZero); this->addChild(menu); this->setKeypadEnabled(true); return true; }
/** * Creates and adds main layout to the screen. */ void CreateNotificationScreen::createMainLayout() { VerticalLayout* mainLayout = new VerticalLayout(); Screen::setMainWidget(mainLayout); ListView* listView = new ListView(); listView->fillSpaceHorizontally(); listView->fillSpaceVertically(); mainLayout->addChild(listView); ListViewItem* listItem; HorizontalLayout* hLayout; Widget* space; // ================ Content body ===================== mContentBody = new EditBox(); listView->addChild(createListViewItem(CONTENT_BODY_LABEL_TEXT,(Widget*) mContentBody)); if ( isAndroid() ) { // ================ Content title ===================== mContentTitle = new EditBox(); listView->addChild(createListViewItem(CONTENT_TITLE_LABEL_TEXT, mContentTitle)); // ================ Ticker text ===================== mTickerText = new EditBox(); listView->addChild(createListViewItem(TICKER_TEXT_LABEL_TEXT, mTickerText)); } else { // ================ Badge number ===================== mBadgeNumber = new EditBox(); mBadgeNumber->setWidth(NUMERIC_EDIT_BOX_WIDTH); mBadgeNumber->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); mBadgeNumber->addEditBoxListener(this); listView->addChild(createListViewItem(BADGE_NUMBER_LABEL_TEXT, mBadgeNumber)); // ================ Alert action ===================== mAlertAction = new EditBox(); mAlertAction->addEditBoxListener(this); listView->addChild(createListViewItem(ALERT_ACTION_LABEL_TEXT, mAlertAction)); } // ================ Play sound ===================== mPlaySound = new CheckBox(); listView->addChild(createListViewItem(PLAY_SOUND_LABEL_TEXT, mPlaySound)); if ( isAndroid() ) { // ================ Sound path===================== mSoundPath = new EditBox(); listView->addChild(createListViewItem(SOUND_PATH_LABEL_TEXT, mSoundPath)); // ================ Vibrate ===================== mVibrate = new CheckBox(); listView->addChild(createListViewItem(VIBRATE_LABEL_TEXT, mVibrate)); mVibrateDuration = new EditBox(); mVibrateDuration->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); listView->addChild(createListViewItem(VIBRATE_DURATION_LABEL_TEXT, mVibrateDuration)); // ================ Flashing LED ===================== mFlash = new CheckBox(); listView->addChild(createListViewItem(FLASH_LABEL_TEXT, mFlash)); // The pattern mFlashColor = new EditBox(); listView->addChild(createListViewItem(FLASH_COLOR_LABEL_TEXT, mFlashColor)); mFlashOnLength = new EditBox(); mFlashOnLength->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); listView->addChild(createListViewItem(FLASH_ON_LABEL_TEXT, mFlashOnLength)); mFlashOffLength = new EditBox(); mFlashOffLength->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); listView->addChild(createListViewItem(FLASH_OFF_LABEL_TEXT, mFlashOffLength)); } // ================ Fire time ===================== mTime = new EditBox(); mTime->setWidth(NUMERIC_EDIT_BOX_WIDTH); mTime->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); listView->addChild(createListViewItem(FIRE_TIME_LABEL_TEXT, mTime)); // ================= Send image button ================ hLayout = new HorizontalLayout(); hLayout->fillSpaceHorizontally(); listItem = new ListViewItem(); listItem->addChild(hLayout); listView->addChild(listItem); mCreateNotificationButton = new ImageButton(); mCreateNotificationButton->setImage(RES_IMAGE); space = this->createSpacer(); hLayout->addChild(space); hLayout->addChild(mCreateNotificationButton); // Align the image button at the center of the layout. // Only after adding the image button widget to layout the widget's width // is available. int spacerWidth = hLayout->getWidth() / 2 - mCreateNotificationButton->getWidth() / 2; space->setWidth(spacerWidth); }