bool ResultScene::init(){ if (!Layer::init()){ return false; } auto visibleSize = Director::getInstance()->getVisibleSize(); auto bgimage = Sprite::create("background/dimension-light.png"); this->addChild(bgimage, Z_BACK); bgimage->setPosition(visibleSize / 2); bgimage->setScale(1.3); auto bgimage2 = Sprite::create("background/water.png"); this->addChild(bgimage2, Z_BACK); bgimage2->setPosition(0, visibleSize.height / 2); bgimage2->setAnchorPoint(Vec2(0, 0.5)); bgimage2->setScale(3, 1.3); bgimage2->setBlendFunc(GL_BLEND_SCREENMODE); bgimage2->setOpacity(200); bgimage2->setTag(100); auto tempText = LabelTTF::create("Total money you get: ", "Segoe UI", 36); tempText->setPosition(100, visibleSize.height - 300); tempText->setHorizontalAlignment(TextHAlignment::LEFT); tempText->setVerticalAlignment(TextVAlignment::CENTER); tempText->setAnchorPoint(Vec2(0, 0.5)); tempText->setTag(101); this->addChild(tempText, Z_UI); auto amountPla = LabelTTF::create("Amount of planaria you make: ", "Segoe UI", 36); amountPla->setPosition(tempText->getPositionX(), tempText->getPositionY() - 60); amountPla->setHorizontalAlignment(TextHAlignment::LEFT); amountPla->setVerticalAlignment(TextVAlignment::CENTER); amountPla->setAnchorPoint(Vec2(0, 0.5)); amountPla->setTag(102); this->addChild(amountPla, Z_UI); auto amountDead = LabelTTF::create("Amount of planaria you cut: ", "Segoe UI", 36); amountDead->setPosition(amountPla->getPositionX(), amountPla->getPositionY() - 60); amountDead->setHorizontalAlignment(TextHAlignment::LEFT); amountDead->setVerticalAlignment(TextVAlignment::CENTER); amountDead->setAnchorPoint(Vec2(0, 0.5)); amountDead->setTag(103); this->addChild(amountDead, Z_UI); this->schedule(schedule_selector(ResultScene::Mainloop)); b2Aquarium = Sprite::create("retry.png"); \ b2Aquarium->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM); \ b2Aquarium->setPosition(visibleSize.width / 2, 0); \ this->addChild(b2Aquarium); return true; }
static inline Layer* makeItem(string sprite, string text, char code, bool numbered=false) { Layer* l = Layer::create(); Layer* s = Layer::create(); auto sp = MAKESPRITE(sprite); l->addChild(s); s->addChild(sp); s->setPosition(Point(-64, -64)); auto t = makeText(text); s->setTag(1); t->setTag(2); l->addChild(t); auto spriteSize = sp->getContentSize(); auto spriteMidPoint = Point( spriteSize.width * 0.5f, spriteSize.height * 0.5f); sp->setPosition(spriteMidPoint); sp->setTag(0); if (numbered) { auto num = Label::createWithBMFont(MATH_FNT, "--"); sp->addChild(num); num->setHorizontalAlignment(TextHAlignment::CENTER); num->setVerticalAlignment(TextVAlignment::BOTTOM); num->setPosition(Point(32, 34)); } return l; }
void WAutoCompleteLineEdit::create(WContainerWidget *parent) { setImplementation(layout_ = new WTable(parent)); setInline(true); setVerticalAlignment(AlignMiddle); lineEdit_ = new WLineEdit(layout_->elementAt(0, 0)); suggestionsList_ = new WTable(layout_->elementAt(1, 0)); suggestionsList_->setPopup(true); suggestionsList_->setPositionScheme(Absolute); WCssDecorationStyle& style = suggestionsList_->decorationStyle(); style.setCursor(WCssDecorationStyle::Default); style.font().setSize(WFont::Smaller); WBorder border(WBorder::Solid); border.setWidth(WBorder::Explicit, WLength(2)); style.setBorder(border); style.setBackgroundColor(Wt::white); connect(lineEdit_, SIGNAL(keyWentUp(int)), this, SLOT(lineEditKeyUp(int))); //connect(lineEdit_, SIGNAL(blurred()), // suggestionsList_, SLOT(hide()), STATIC); suggestionsList_->hide(); }
void Label::setParameter(const String& name, const String& value) { if(name == "caption") this->setCaption(value); else if(name == "autoSizeX") this->setAutoSizeX(value=="true"?true:false); else if(name == "autoSizeY") this->setAutoSizeY(value=="true"?true:false); else if(name == "horizontalAlignment") { if(value == "left") setHorizontalAlignment(HA_LEFT); else if(value == "right") setHorizontalAlignment(HA_RIGHT); else if(value == "center") setHorizontalAlignment(HA_CENTER); else maPanic(0, "MAUI::Label wrong parameter"); } else if(name == "verticalAlignment") { if(value == "top") setVerticalAlignment(VA_TOP); else if(value == "bottom") setVerticalAlignment(VA_BOTTOM); else if(value == "center") setVerticalAlignment(VA_CENTER); else maPanic(0, "MAUI::Label wrong parameter"); } else Widget::setParameter(name, value); }
void MenuControl::setPropertyOverride(const std::string& _key, const std::string& _value) { if (_key == "VerticalAlignment") setVerticalAlignment(utility::parseValue<bool>(_value)); else { Base::setPropertyOverride(_key, _value); return; } eventChangeProperty(this, _key, _value); }
void ItemBox::setPropertyOverride(const std::string& _key, const std::string& _value) { /// @wproperty{ItemBox, VerticalAlignment, bool} Вертикальное выравнивание. if (_key == "VerticalAlignment") setVerticalAlignment(utility::parseValue<bool>(_value)); else { Base::setPropertyOverride(_key, _value); return; } eventChangeProperty(this, _key, _value); }
void ScrollBar::setPropertyOverride(const std::string& _key, const std::string& _value) { /// @wproperty{ScrollBar, Range, size_t} Диапазон прокрутки. if (_key == "Range") setScrollRange(utility::parseValue<size_t>(_value)); /// @wproperty{ScrollBar, RangePosition, size_t} Положение прокрутки. else if (_key == "RangePosition") setScrollPosition(utility::parseValue<size_t>(_value)); /// @wproperty{ScrollBar, Page, size_t} Шаг прокрутки при нажатии на кнопку начала или конца. else if (_key == "Page") setScrollPage(utility::parseValue<size_t>(_value)); /// @wproperty{ScrollBar, ViewPage, size_t} Шаг прокрутки при нажатии на одну из частей от кнопки до трекера. else if (_key == "ViewPage") setScrollViewPage(utility::parseValue<size_t>(_value)); /// @wproperty{ScrollBar, WheelPage, size_t} Шаг прокрутки при прокрутке колесиком мыши. else if (_key == "WheelPage") setScrollWheelPage(utility::parseValue<size_t>(_value)); /// @wproperty{ScrollBar, MoveToClick, bool} Режим перескакивания бегунка к месту клика. else if (_key == "MoveToClick") setMoveToClick(utility::parseValue<bool>(_value)); /// @wproperty{ScrollBar, VerticalAlignment, bool} Вертикальное выравнивание. else if (_key == "VerticalAlignment") setVerticalAlignment(utility::parseValue<bool>(_value)); /// @wproperty{ScrollBar, Repeat, bool} Sets whether scrollbar buttons should be triggered repeatedly so long as the mouse button is pressed down. else if (_key == "Repeat") setRepeatEnabled(utility::parseValue<bool>(_value)); /// @wproperty{ScrollBar, RepeatTriggerTime, float} How long the mouse needs to be pressed on a scrollbar button for repeating to start. else if (_key == "RepeatTriggerTime") setRepeatTriggerTime(utility::parseValue<float>(_value)); /// @wproperty{ScrollBar, RepeatStepTime, float) The time between each repeat step once repeating has started. else if (_key == "RepeatStepTime") setRepeatStepTime(utility::parseValue<float>(_value)); else { Base::setPropertyOverride(_key, _value); return; } eventChangeProperty(this, _key, _value); }
void RogueScene::logMessage(const char * pszFormat, ...) { char szBuf[kMaxLogLen+1] = {0}; va_list ap; va_start(ap, pszFormat); vsnprintf(szBuf, kMaxLogLen, pszFormat, ap); va_end(ap); CCLOG("logMessage: %s", szBuf); auto pGameLogNode = getChildByTag(RogueScene::kGameLogTag); // とりあえず子要素がないなら無理 if (!pGameLogNode || pGameLogNode->getChildrenCount() <= 0) { return; } auto pGameLogText = static_cast<LabelTTF*>(pGameLogNode->getChildren().at(0)); // TODO: 1子しかaddしてないから動く。ちゃんとしないと・・・ if (pGameLogText) { // TODO: 別クラスにしてログをlistで保持する。デフォルトの表示は1件だけで、center寄せ表示でいいかと auto pMessage = String::create(szBuf); pMessage->append("\n"); std::string nowString = pGameLogText->getString(); int count = f_r(nowString, '\n'); // 3行まで表示 if (count >= 3) { int size = nowString.size(); unsigned int loc = nowString.find_last_of('\n', size); CCLOG("logMessage: loc = %d size = %d", loc, size); if (loc != std::string::npos) { nowString.erase(loc, nowString.size() - loc); } } pMessage->append(nowString); pGameLogText->setString(pMessage->getCString()); pGameLogText->setVerticalAlignment(cocos2d::TextVAlignment::TOP); pGameLogText->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT); pGameLogText->setPosition(Point(pGameLogText->getFontSize() / 4 + pGameLogText->getContentSize().width / 2, pGameLogNode->getContentSize().height - pGameLogText->getContentSize().height / 2 - pGameLogText->getFontSize() / 4)); } }
TableViewCell* Ranking::tableCellAtIndex(TableView *table, ssize_t idx) { RankingData *rankingData = _rankingData.at(idx); table->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN); TableViewCell *cell = table->dequeueCell(); if (!cell) { cell = new TableViewCell(); cell->autorelease(); } cell->removeAllChildren(); auto colorLayer = LayerColor::create(); colorLayer->setAnchorPoint(Point::ZERO); colorLayer->setContentSize(Size(_tableViewRanking->getBoundingBox().size.width, TableViewItemHeightValue.asFloat())); colorLayer->setPosition(Vec2(0 * _tableViewRanking->getBoundingBox().size.width, 0)); cell->addChild(colorLayer); string numberRanking; ostringstream convert2; convert2 << idx + 1; numberRanking = convert2.str(); auto padding = 25; auto number = Label::createWithTTF(numberRanking, MainRegularFont, 60); number->setContentSize(Size(_tableViewRanking->getBoundingBox().size.width / _totalLabels - padding, TableViewItemHeightValue.asFloat())); number->setWidth(_tableViewRanking->getBoundingBox().size.width / _totalLabels); number->setHeight(TableViewItemHeightValue.asFloat()); number->setVerticalAlignment(TextVAlignment::CENTER); number->setHorizontalAlignment(TextHAlignment::LEFT); number->setAnchorPoint(Point::ZERO); if (idx == 0) { number->setTextColor(IkasPurple); } else { number->setTextColor(IkasPurpleLight); } number->setPosition(Vec2(0 * _tableViewRanking->getBoundingBox().size.width + padding/ _totalLabels, 0)); cell->addChild(number); auto name = Label::createWithTTF(rankingData->getuser(), MainRegularFont, 60); name->setContentSize(Size(_tableViewRanking->getBoundingBox().size.width / _totalLabels, TableViewItemHeightValue.asFloat())); name->setWidth(_tableViewRanking->getBoundingBox().size.width / _totalLabels); name->setHeight(TableViewItemHeightValue.asFloat()); name->setVerticalAlignment(TextVAlignment::CENTER); name->setHorizontalAlignment(TextHAlignment::CENTER); name->setAnchorPoint(Point::ZERO); if (idx == 0) { name->setTextColor(IkasPurple); } else { name->setTextColor(IkasPurpleLight); } name->setPosition(Vec2(0 * _tableViewRanking->getBoundingBox().size.width / _totalLabels, 0)); cell->addChild(name); string points; ostringstream convert; convert << rankingData->getpoints(); points = convert.str(); auto pointsLabel = Label::createWithTTF(points, MainRegularFont, 60); pointsLabel->setContentSize(Size(_tableViewRanking->getBoundingBox().size.width / _totalLabels, TableViewItemHeightValue.asFloat())); pointsLabel->setHeight(TableViewItemHeightValue.asFloat()); pointsLabel->setWidth(_tableViewRanking->getBoundingBox().size.width / _totalLabels); pointsLabel->setVerticalAlignment(TextVAlignment::CENTER); pointsLabel->setHorizontalAlignment(TextHAlignment::CENTER); pointsLabel->setAnchorPoint(Point::ZERO); if (idx == 0) { pointsLabel->setTextColor(IkasPurple); } else { pointsLabel->setTextColor(IkasPurpleLight); } pointsLabel->setPosition(Vec2(1 * _tableViewRanking->getBoundingBox().size.width / _totalLabels, 0)); cell->addChild(pointsLabel); // // if (idx % 2 == 0) { // number->setTextColor(IkasWhite); // name->setTextColor(IkasWhite); // pointsLabel->setTextColor(IkasWhite); // colorLayer->setColor(Color3B(IkasRed)); // colorLayer->setOpacity(60); // } else { // number->setTextColor(IkasRed); // name->setTextColor(IkasRed); // pointsLabel->setTextColor(IkasRed); // colorLayer->setColor(Color3B(IkasWhite)); // colorLayer->setOpacity(0); // } LayerColor *topSeparator; if (idx % 2 == 0) { topSeparator = LayerColor::create(IkasPurpleLight); } else { topSeparator = LayerColor::create(IkasPurpleLightAlpha); } topSeparator->setContentSize(Size(_tableViewRanking->getBoundingBox().size.width, 2)); topSeparator->setPosition(Vec2(0, TableViewItemHeightValue.asFloat() - 4)); topSeparator->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT); cell->addChild(topSeparator); if (idx == _rankingData.size() - 1) { if (idx % 2 != 0) { topSeparator = LayerColor::create(IkasPurpleLight); } else { topSeparator = LayerColor::create(IkasPurpleLightAlpha); } topSeparator->setContentSize(Size(_tableViewRanking->getBoundingBox().size.width, 2)); topSeparator->setPosition(Vec2(0, 0)); topSeparator->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT); cell->addChild(topSeparator); } return cell; }
bool ItemWindowLayer::initWithContentSize(Size contentSize) { if (!LayerColor::init()) { return false; } setContentSize(contentSize); int padding = 2; // アイテム一覧レイヤー(左側) std::list<std::string> itemNameList; for (DropItemSprite::DropItemDto dropItem : m_itemDtoList) { itemNameList.push_back(dropItem.name); } auto pItemListLayer = TableViewTestLayer::createWithTextArray(itemNameList, Size(contentSize.width / 2, contentSize.height)); pItemListLayer->setColor(Color3B::BLACK); pItemListLayer->setOpacity(128); pItemListLayer->setPosition(Point( contentSize.width / 2 - pItemListLayer->getContentSize().width - padding, contentSize.height / 2 - pItemListLayer->getContentSize().height / 2)); pItemListLayer->setCallback([this](Object* pObject, long touchedIdx) { // 行選択時 CCLOG(" touched idx = %ld", touchedIdx); // 同じ行連打は無視 if (m_showItemDetailIdx == touchedIdx) { return; } // touched DropItemDto auto it = m_itemDtoList.begin(); std::advance(it, touchedIdx); auto dropItemDto = (DropItemSprite::DropItemDto) *it; this->setItemDetail(&dropItemDto); // 表示indexを更新 m_showItemDetailIdx = touchedIdx; }); pItemListLayer->setTag(ItemWindowLayer::ItemTableLayerTag); this->addChild(pItemListLayer); // アイテム詳細レイヤー(右側) auto pItemDetailLayer = LayerColor::create(); pItemDetailLayer->setColor(Color3B::BLACK); pItemDetailLayer->setOpacity(128); pItemDetailLayer->setContentSize(Size(contentSize.width / 2, contentSize.height)); pItemDetailLayer->setPosition(Point(contentSize.width / 2 + padding, 0)); pItemDetailLayer->setTag(ItemDetailLayerTag); // アイテム名 auto pItemNameTitleLabel = LabelTTF::create("なまえ", GAME_FONT(16), 16); pItemNameTitleLabel->setColor(Color3B::WHITE); pItemNameTitleLabel->setVerticalAlignment(cocos2d::TextVAlignment::TOP); pItemNameTitleLabel->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT); pItemNameTitleLabel->setPosition(Point( pItemNameTitleLabel->getContentSize().width / 2 + pItemNameTitleLabel->getFontSize() / 2, pItemDetailLayer->getContentSize().height - pItemNameTitleLabel->getContentSize().height / 2 - pItemNameTitleLabel->getFontSize() / 2)); pItemDetailLayer->addChild(pItemNameTitleLabel); auto pItemNameLabel = LabelTTF::create(ITEM_LAYER_NAME_DEFAULT, GAME_FONT(10), 10); pItemNameLabel->setColor(Color3B::WHITE); pItemNameLabel->setPosition(Point( pItemDetailLayer->getContentSize().width * 0.5, pItemDetailLayer->getContentSize().height * 0.75)); pItemNameLabel->setTag(ItemWindowLayer::ItemNameTag); pItemDetailLayer->addChild(pItemNameLabel); // アイテム説明 auto pItemDetailTitleLabel = LabelTTF::create("せつめい", GAME_FONT(16), 16); pItemDetailTitleLabel->setColor(Color3B::WHITE); pItemDetailTitleLabel->setVerticalAlignment(cocos2d::TextVAlignment::TOP); pItemDetailTitleLabel->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT); pItemDetailTitleLabel->setPosition(Point( pItemDetailTitleLabel->getContentSize().width / 2 + pItemDetailTitleLabel->getFontSize() / 2, pItemDetailLayer->getContentSize().height / 2 - pItemDetailTitleLabel->getContentSize().height / 2 - pItemDetailTitleLabel->getFontSize() / 2)); pItemDetailLayer->addChild(pItemDetailTitleLabel); auto pItemDetailLabel = LabelTTF::create(ITEM_LAYER_DETAIL_DEFAULT, GAME_FONT(10), 10); pItemDetailLabel->setColor(Color3B::WHITE); pItemDetailLabel->setPosition(Point( pItemDetailLayer->getContentSize().width * 0.5, pItemDetailLayer->getContentSize().height * 0.25)); pItemDetailLabel->setTag(ItemWindowLayer::ItemDetailTag); pItemDetailLayer->addChild(pItemDetailLabel); // ----------------------------- // メニューボタン float addNextMenuPositonX = 8; // 捨てるボタン auto pMenuItemDrop = ItemWindowLayer::createMenuItemSprite(Color3B::RED, [this](Object* pSeneder) { // hoge CCLOG("item drop menu pressed"); if (m_showItemDetailIdx < 0) { return; } if (m_itemDropMenuCallback) { auto it = m_itemDtoList.begin(); std::advance(it, m_showItemDetailIdx); auto dropItemDto = (DropItemSprite::DropItemDto) *it; // 削除 m_itemDtoList.erase(it); m_itemDropMenuCallback(pSeneder, dropItemDto); } }); pMenuItemDrop->setPosition(Point(pMenuItemDrop->getContentSize().width / 2 + addNextMenuPositonX , pMenuItemDrop->getContentSize().height / 2)); addNextMenuPositonX += pMenuItemDrop->getContentSize().width + 8; // 使用ボタン auto pMenuItemUse = ItemWindowLayer::createMenuItemSprite(Color3B::GRAY, [this](Object* pSeneder) { // hoge CCLOG("item use menu pressed"); if (m_showItemDetailIdx < 0) { return; } if (m_itemUseMenuCallback) { auto it = m_itemDtoList.begin(); std::advance(it, m_showItemDetailIdx); auto dropItemDto = (DropItemSprite::DropItemDto) *it; // 削除 m_itemDtoList.erase(it); m_itemUseMenuCallback(pSeneder, dropItemDto); } }); pMenuItemUse->setPosition(Point(pMenuItemDrop->getContentSize().width / 2 + addNextMenuPositonX, pMenuItemDrop->getContentSize().height / 2)); addNextMenuPositonX += pMenuItemUse->getContentSize().width + 8; auto pMenu = Menu::create(pMenuItemDrop, pMenuItemUse, NULL); pMenu->setPosition(Point::ZERO); pItemDetailLayer->addChild(pMenu); this->addChild(pItemDetailLayer); return true; }
bool ActivityView::init() { if (!PopupBaseView::init()) { return false; } setIsHDPanel(true); if (m_obj->type != 6) return false; CCLoadSprite::doResourceByCommonIndex(500, true); CCLoadSprite::doResourceByCommonIndex(502, true); CCLoadSprite::doResourceByCommonIndex(506, true); auto size = CCDirector::sharedDirector()->getWinSize(); this->setContentSize(CCSize(640, 852)); if (CCCommonUtils::isIosAndroidPad()) { this->setContentSize(CCSize(1536, 2048)); } CCBLoadFile("ActivityView", this, this); if (CCCommonUtils::isIosAndroidPad()) { m_bottomNode->setPositionY(m_bottomNode->getPositionY() - (size.height - 2048)); m_listNode->setPositionY(m_listNode->getPositionY() - (size.height - 2048)); m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + size.height - 2048)); } else { m_bottomNode->setPositionY(m_bottomNode->getPositionY() - (size.height - 852)); m_listNode->setPositionY(m_listNode->getPositionY() - (size.height - 852)); m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + size.height - 852)); } if (m_obj->exchange == "1" || m_obj->exchange == "2") { m_bottomNode->setVisible(true); } else { m_bottomNode->setVisible(false); if (CCCommonUtils::isIosAndroidPad()) { m_listNode->setPositionY(m_listNode->getPositionY() - 178); m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + 178)); } else { m_listNode->setPositionY(m_listNode->getPositionY() - 92); m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + 92)); } } m_titleLabel->setString(_lang("150215")); CCCommonUtils::setButtonTitle(m_rwdBtn, _lang("133076").c_str()); Node* node = Node::create(); CCLabelIF* label = nullptr; Sprite* spr = nullptr; float height = 0; { if (!m_obj->rewardIds.empty()) { if (m_obj->showDialogs.size() > 0) { height -= 20; if (CCCommonUtils::isIosAndroidPad()) { height -= 20; } } for (auto it = m_obj->showDialogs.begin(); it != m_obj->showDialogs.end(); ++it) { vector<string> tVec; CCCommonUtils::splitString(*it, ";", tVec); string showStr(""); if (tVec.size() == 1) { showStr = _lang(tVec[0]); } else if (tVec.size() == 2) { showStr = _lang_1(tVec[0].c_str(), (CCCommonUtils::getNameById(tVec[1])).c_str()); } else if (tVec.size() == 3) { showStr = _lang_2(tVec[0].c_str(), (CCCommonUtils::getNameById(tVec[1])).c_str(), (CCCommonUtils::getNameById(tVec[2])).c_str()); } else if (tVec.size() == 4) { showStr = _lang_3(tVec[0].c_str(), (CCCommonUtils::getNameById(tVec[1])).c_str(), (CCCommonUtils::getNameById(tVec[2])).c_str(), (CCCommonUtils::getNameById(tVec[3])).c_str()); } label = CCLabelIF::create(showStr.c_str()); label->setFontSize(20); if (CCCommonUtils::isIosAndroidPad()) { label->setFontSize(40); } label->setColor(ccBLACK); label->setAnchorPoint(Vec2(0.5, 1)); label->setDimensions(Size(580, 0)); if (CCCommonUtils::isIosAndroidPad()) { label->setDimensions(Size(1300, 0)); } label->setHorizontalAlignment(TextHAlignment::CENTER); label->setVerticalAlignment(TextVAlignment::TOP); label->setPosition(Vec2(0, height)); node->addChild(label); height -= label->getContentSize().height * label->getOriginScaleY(); } height -= 5; if (CCCommonUtils::isIosAndroidPad()) { height -= 5; } //有几率获得 label = CCLabelIF::create(_lang("150217").c_str()); label->setFontSize(18); if (CCCommonUtils::isIosAndroidPad()) { label->setFontSize(36); } label->setAnchorPoint(Vec2(0.5, 1)); label->setPosition(Vec2(0, height)); label->setColor({139, 29, 20}); label->setHorizontalAlignment(TextHAlignment::CENTER); label->setVerticalAlignment(TextVAlignment::TOP); node->addChild(label); height -= label->getContentSize().height * label->getOriginScaleY(); //展示奖励 int cnt = m_obj->rewardIds.size(); int hang = ceil(cnt / 6.0); for (int i = 1; i <= hang; ++i) { if (i < hang) { for (int j = 1; j <= 6; ++j) { ActivityRwdShowCell* cell = ActivityRwdShowCell::create(m_obj->rewardIds.at(j - 1 + (i - 1) * 6)); cell->setPositionX(- 80 * 6 / 2 + 80 / 2 + (j - 1) * 80); cell->setPositionY(height - 40); if (CCCommonUtils::isIosAndroidPad()) { cell->setPositionX(- 160 * 6 / 2 + 160 / 2 + (j - 1) * 160); cell->setPositionY(height - 80); } node->addChild(cell); } height -= 80; if (CCCommonUtils::isIosAndroidPad()) { height -= 80; } } else { int leftCnt = cnt - (i - 1) * 6; for (int j = 1; j <= leftCnt; ++j) { ActivityRwdShowCell* cell = ActivityRwdShowCell::create(m_obj->rewardIds.at((i - 1) * 6 + j - 1)); cell->setPositionX(- (80 * leftCnt) / 2 + 80 / 2 + (j - 1) * 80); cell->setPositionY(height - 40); if (CCCommonUtils::isIosAndroidPad()) { cell->setPositionX(- 160 * leftCnt / 2 + 160 / 2 + (j - 1) * 160); cell->setPositionY(height - 80); } node->addChild(cell); } height -= 80; if (CCCommonUtils::isIosAndroidPad()) { height -= 80; } } } //空 height -= 10; if (CCCommonUtils::isIosAndroidPad()) { height -= 10; } //横线 spr = CCLoadSprite::createSprite("Items_tips3_lottery.png"); spr->setAnchorPoint(Vec2(0.5, 0.5)); spr->setPosition(0, height); node->addChild(spr); if (CCCommonUtils::isIosAndroidPad()) { spr->setScale(2); } //空 height -= 10; if (CCCommonUtils::isIosAndroidPad()) { height -= 10; } //剧情简介 label = CCLabelIF::create(_lang("150216").c_str()); label->setAnchorPoint(Vec2(0.5, 1)); label->setColor(ccBLACK); label->setFontSize(20); if (CCCommonUtils::isIosAndroidPad()) { label->setFontSize(40); } label->setPosition(0, height); label->setHorizontalAlignment(TextHAlignment::CENTER); label->setVerticalAlignment(TextVAlignment::TOP); node->addChild(label); height -= label->getContentSize().height * label->getOriginScaleY(); //空 height -= 10; if (CCCommonUtils::isIosAndroidPad()) { height -= 10; } } //正文 string mStory = _lang(m_obj->story); mStory.append("\n\n\n"); label = CCLabelIF::create(mStory.c_str()); label->setFontSize(20); if (CCCommonUtils::isIosAndroidPad()) { label->setFontSize(40); } label->setDimensions(Size(580, 0)); if (CCCommonUtils::isIosAndroidPad()) { label->setDimensions(Size(1300, 0)); } label->setAnchorPoint(Vec2(0.5, 1)); label->setColor({85, 62, 31}); label->setPosition(0, height); label->setHorizontalAlignment(TextHAlignment::CENTER); label->setVerticalAlignment(TextVAlignment::TOP); node->addChild(label); height -= label->getContentSize().height * label->getOriginScaleY(); } ScrollView* view = ScrollView::create(m_listNode->getContentSize()); if (abs(height) < m_listNode->getContentSize().height) { node->setPositionY(m_listNode->getContentSize().height / 2.0 + abs(height) / 2.0); height = -m_listNode->getContentSize().height; } else { node->setPositionY(abs(height)); } view->setContentSize(Size(m_listNode->getContentSize().width, abs(height))); view->addChild(node); node->setPositionX(view->getContentSize().width / 2); // node->setPositionY(abs(height)); view->setContentOffset(Vec2(0, m_listNode->getContentSize().height - view->getContentSize().height)); view->setDirection(ScrollView::Direction::VERTICAL); m_listNode->addChild(view); view->setDelegate(this); bool st = false; if (LuaController::getInstance()->checkActLuaValid(m_obj)) { CCNode* node = LuaController::getInstance()->createActivityAdCell(m_obj); if (node && node->getChildrenCount()) { m_picNode->addChild(node); if (CCCommonUtils::isIosAndroidPad()) { float w = (1536.0 - 1156.0) / 2.0; float h = 645; node->setContentSize(CCSize(0, 0)); node->setScaleX(1156.0 / 640.0); node->setScaleY(645.0 / 357.0); auto layer1 = CCModelLayerColor::create(); layer1->setAnchorPoint(ccp(0, 0)); layer1->setContentSize(CCSize(w, h)); layer1->setPosition(-w, 0); layer1->setOpacity(255); layer1->setColor(ccBLACK); // layer1->setTouchPriority(-999); m_picNode->addChild(layer1); layer1 = CCModelLayerColor::create(); layer1->setAnchorPoint(CCPointZero); layer1->setPosition(ccp(1156, 0)); layer1->setContentSize(CCSize(w, h)); layer1->setOpacity(255); layer1->setColor(ccBLACK); // layer1->setTouchPriority(-999); m_picNode->addChild(layer1); } } else { st = true; } } else { st = true; } if (st) { auto nameTTF = CCLabelIF::create(m_obj->name.c_str()); auto infoTTF = CCLabelIF::create(m_obj->desc.c_str()); auto bgImg = CCLoadSprite::createSprite("activity_ad_beiyong.png"); nameTTF->setPosition(ccp(16,245)); nameTTF->setAnchorPoint(ccp(0, 1)); nameTTF->setFontSize(36); nameTTF->setColor({255,219,117}); nameTTF->setHorizontalAlignment(kCCTextAlignmentLeft); nameTTF->setVerticalAlignment(kCCVerticalTextAlignmentTop); nameTTF->setDimensions(CCSize(0, 0)); infoTTF->setPosition(ccp(16,201)); infoTTF->setAnchorPoint(ccp(0, 1)); infoTTF->setColor({0, 249, 0}); infoTTF->setHorizontalAlignment(kCCTextAlignmentLeft); infoTTF->setVerticalAlignment(kCCVerticalTextAlignmentTop); infoTTF->setDimensions(CCSize(300, 0)); bgImg->setAnchorPoint(ccp(0, 0)); bgImg->setPosition(ccp(0, 0)); auto node = CCNode::create(); node->addChild(bgImg); node->addChild(nameTTF); node->addChild(infoTTF); m_picNode->addChild(node); if (CCCommonUtils::isIosAndroidPad()) { float w = (1536.0 - 1156.0) / 2.0; float h = 645; node->setContentSize(CCSize(0, 0)); node->setScaleX(1156.0 / 640.0); node->setScaleY(645.0 / 357.0); auto layer1 = CCModelLayerColor::create(); layer1->setAnchorPoint(ccp(0, 0)); layer1->setContentSize(CCSize(w, h)); layer1->setPosition(-w, 0); layer1->setOpacity(255); layer1->setColor(ccBLACK); // layer1->setTouchPriority(-999); m_picNode->addChild(layer1); layer1 = CCModelLayerColor::create(); layer1->setAnchorPoint(CCPointZero); layer1->setPosition(ccp(1156, 0)); layer1->setContentSize(CCSize(w, h)); layer1->setOpacity(255); layer1->setColor(ccBLACK); // layer1->setTouchPriority(-999); m_picNode->addChild(layer1); } } if (m_obj->exchange == "2") { if (ActivityController::getInstance()->m_exc2Data.find(m_obj->id) == ActivityController::getInstance()->m_exc2Data.end()) { ActivityController::getInstance()->startGetAct6Data(); } else { if (!ActivityController::getInstance()->checkIsToday(ActivityController::getInstance()->m_exc2RefInfo[m_obj->id].m_refreshTime)) { ActivityController::getInstance()->m_exc2RefInfo[m_obj->id].m_refreshTime = GlobalData::shared()->getTimeStamp(); ActivityController::getInstance()->m_exc2RefInfo[m_obj->id].m_refresh = 0; } } } else if (m_obj->exchange == "1") { if (!ActivityController::getInstance()->isAct1DataInit(m_obj->id)) { ActivityController::getInstance()->startGetAct6Data(); } else { ActivityController::getInstance()->checkAct1ReFreshTimes(m_obj->id); // if (ActivityController::getInstance()->isAct1DataShouldRefresh(m_obj->id)) // { // ActivityController::getInstance()->startAct6Refresh(m_obj->id); // } } } return true; }
/** * Constructor. * <p> * Builds an animation from the animation type so that it can be drawn later. * @param model * @param rect * @param animationType */ ImageView::ImageView(Model *model, const SDL_Rect &rect, AnimationType animationType) : RectangleView(model, rect) { animation = animationFactory->build(animationType); setHorizontalAlignment(HorizontalAlignment::LEFT); setVerticalAlignment(VerticalAlignment::BOTTOM); }