本文整理汇总了C++中LayerColor::setContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerColor::setContentSize方法的具体用法?C++ LayerColor::setContentSize怎么用?C++ LayerColor::setContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerColor
的用法示例。
在下文中一共展示了LayerColor::setContentSize方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tableCellHighlight
void SelectMissionScene::tableCellHighlight(TableView* table, TableViewCell* cell)
{
LayerColor *shadeLayer = LayerColor::create(Color4B(0, 0, 170, 100));
shadeLayer->setContentSize(Size(540, 100));
shadeLayer->setTag(5000);
cell->addChild(shadeLayer);
}
示例2: init
void MessageItem::init(char *msg, int time)
{
_msg = msg;
_time = time;
_curTime = 0;
Size size = Size(400, 0);
_node = LayerRGBA::create();
_node->retain();
LayerColor *bg = LayerColor::create(Color4B(0x0, 0x0, 0x0, 0xaa), 20, 20);
bg->setAnchorPoint(Point(0.5f, 0.5f));
bg->ignoreAnchorPointForPosition(false);
_node->addChild(bg);
//Marker Felt
auto label1 = LabelTTF::create(_msg, "Marker Felt", 20, size,
TextHAlignment::CENTER,
TextVAlignment::TOP);
size.height = label1->getContentSize().height + 20;
bg->setContentSize(size);
label1->setAnchorPoint(Point(0.5f, 0.5f));
_node->addChild(label1);
}
示例3: init
bool GameNext::init()
{
//////////////////////////////
// 1. super init first
if (!Scene::init())
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
if(game_round<=9)
{
gr_pic = "0" + Value(game_round).asString();
}else if(game_round>=10)
{
gr_pic = Value(game_round).asString();
}
if((game_level-1)<=9)
{
gl_pic = "0" + Value(game_level-1).asString();
}else if((game_level-1)>=10)
{
gl_pic = Value(game_level-1).asString();
}
//被弄成灰色的截图
auto ac = Sprite::create(picNext);
ac->setAnchorPoint(Vec2(0,0));
ac->setPosition(Vec2(0,0));
ac->setScaleX(visibleSize.width/ac->getTextureRect().getMaxX()); //设置精灵宽度缩放比例
ac->setScaleY(visibleSize.height/ac->getTextureRect().getMaxY());
this->addChild(ac,100);
//半透明层,在截图之上
LayerColor* layerColor = CCLayerColor::create();
layerColor->setColor(cocos2d::Color3B(0, 0, 0));
layerColor->setOpacity(150);
layerColor->setContentSize(Size(visibleSize.width, visibleSize.height));
this->addChild(layerColor,101);
//next小方块的背景
auto gameover = Sprite::create("setting/gamenext.png");
gameover->setPosition(Vec2(origin.x + visibleSize.width/2,origin.y + visibleSize.height/2));
this->addChild(gameover,102);
scheduleUpdate();
return true;
}
示例4: createBottomBar
//TODO 屏蔽事件穿透
void BattleScene::createBottomBar()
{
LayerColor *bottom = LayerColor::create(Color4B(0, 0, 100, 100));
bottom->setContentSize(Size(WINSIZE.width, 120));
bottom->setPosition(Point(0, 0));
addChild(bottom);
int totalCount = 11;
int index = 0;
Vector<MenuItem *> items;
auto soldierInCamp = BattleData::getInstance()->getAttackSoldierInCamp();
map<int, vector<DSoldier *>>::iterator it;
for(it=soldierInCamp.begin(); it!=soldierInCamp.end(); it++)
{
MenuItemImage *item = MenuItemImage::create("ui/616.0.png", "ui/617.0.png", "ui/618.0.png", CC_CALLBACK_1(BattleScene::selectArmy, this));
item->setTag(it->first);
items.pushBack(item);
index++;
//head
Size size = item->getContentSize();
char img[20];
sprintf(img, "ui/%d.png", it->first / 100);
auto head = Sprite::create(img);
head->setAnchorPoint(Point(0.5, 0.5));
head->setPosition(size.width/2, size.height/2);
item->addChild(head);
char text[20];
sprintf(text, "X %d", it->second.size());
TTFConfig config("fonts/tahoma.ttf",16);
auto count = Label::createWithTTF(config, text, TextHAlignment::LEFT);
count->setPosition(size.width/2, size.height - count->getContentSize().height);
item->addChild(count);
//初始化为第一个兵种
if (m_selectedSoldierType <= 0)
{
m_selectedSoldierType = it->first;
}
}
for (int i = index; i < totalCount; i++)
{
MenuItemImage *item = MenuItemImage::create("ui/616.0.png", "ui/617.0.png", "ui/618.0.png", CC_CALLBACK_1(BattleScene::selectArmy, this));
item->setEnabled(false);
items.pushBack(item);
}
Size bottomSize = bottom->getContentSize();
Sprite *spItem = Sprite::create("ui/618.0.png");
Size itemSize = spItem->getContentSize();
float padding = (bottomSize.width - itemSize.width * totalCount) / (totalCount + 1);
UIRadioButton *radio = UIRadioButton::createWithArray(items);
radio->alignItemsHorizontallyWithPadding(padding);
radio->setPosition(Point(bottomSize.width / 2, bottomSize.height / 2));
radio->setSelectedIndex(0);
bottom->addChild(radio);
}
示例5: init
bool GameOver::init()
{
//////////////////////////////
// 1. super init first
if (!Scene::init())
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
auto ac = Sprite::create(picOver);
ac->setAnchorPoint(Vec2(0,0));
ac->setPosition(Vec2(0,0));
ac->setScaleX(visibleSize.width/ac->getTextureRect().getMaxX()); //设置精灵宽度缩放比例
ac->setScaleY(visibleSize.height/ac->getTextureRect().getMaxY());
this->addChild(ac,100);
//半透明层
LayerColor* layerColor = CCLayerColor::create();
layerColor->setColor(cocos2d::Color3B(0, 0, 0));
layerColor->setOpacity(150);
layerColor->setContentSize(Size(visibleSize.width, visibleSize.height));
this->addChild(layerColor,101);
auto gameover = Sprite::create("setting/gameover.png");
//gameover->setAnchorPoint(Vec2(0,0));
gameover->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height/2));
this->addChild(gameover,102);
scheduleUpdate();
return true;
}
示例6: init
bool GameWinLayer::init()
{
if (!Layer::init())
{
return false;
}
Size visibleSize = Director::sharedDirector()->getVisibleSize();
// finish layer
LayerColor* layerColor = LayerColor::create();
layerColor->setColor(Color3B(0, 0, 0));
layerColor->setOpacity(150);
layerColor->setContentSize(Size(visibleSize.width, visibleSize.height));
this->addChild(layerColor, 1);
return true;
}
示例7: addChild
// on "init" you need to initialize your instance
bool Bug914Layer::init()
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if (BugsTestBaseLayer::init())
{
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesBegan = CC_CALLBACK_2(Bug914Layer::onTouchesBegan, this);
listener->onTouchesMoved = CC_CALLBACK_2(Bug914Layer::onTouchesMoved, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
// ask director the the window size
auto size = Director::getInstance()->getWinSize();
LayerColor *layer;
for( int i=0;i < 5;i++)
{
layer = LayerColor::create(Color4B(i*20, i*20, i*20,255));
layer->setContentSize(Size(i*100, i*100));
layer->setPosition(Vec2(size.width/2, size.height/2));
layer->setAnchorPoint(Vec2(0.5f, 0.5f));
layer->ignoreAnchorPointForPosition(false);
addChild(layer, -1-i);
}
// create and initialize a Label
auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 64.0f);
auto item1 = MenuItemFont::create("restart", CC_CALLBACK_1(Bug914Layer::restart, this));
auto menu = Menu::create(item1, nullptr);
menu->alignItemsVertically();
menu->setPosition(Vec2(size.width/2, 100));
addChild(menu);
// position the label on the center of the screen
label->setPosition(Vec2( size.width /2 , size.height/2 ));
// add the label as a child to this Layer
addChild(label);
return true;
}
return false;
}
示例8: setTouchEnabled
// on "init" you need to initialize your instance
bool Bug914Layer::init()
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if (BugsTestBaseLayer::init())
{
setTouchEnabled(true);
// ask director the the window size
Size size = Director::getInstance()->getWinSize();
LayerColor *layer;
for( int i=0;i < 5;i++)
{
layer = LayerColor::create(Color4B(i*20, i*20, i*20,255));
layer->setContentSize(Size(i*100, i*100));
layer->setPosition(Point(size.width/2, size.height/2));
layer->setAnchorPoint(Point(0.5f, 0.5f));
layer->ignoreAnchorPointForPosition(false);
addChild(layer, -1-i);
}
// create and initialize a Label
LabelTTF *label = LabelTTF::create("Hello World", "Marker Felt", 64);
MenuItem *item1 = MenuItemFont::create("restart", CC_CALLBACK_1(Bug914Layer::restart, this));
Menu *menu = Menu::create(item1, NULL);
menu->alignItemsVertically();
menu->setPosition(Point(size.width/2, 100));
addChild(menu);
// position the label on the center of the screen
label->setPosition(Point( size.width /2 , size.height/2 ));
// add the label as a child to this Layer
addChild(label);
return true;
}
return false;
}
示例9: init
bool WaitingNode::init()
{
if (!CustomNode::init())
{
return false;
}
LayerColor* pBackground = LayerColor::create(ccc4(7, 25, 44, 150));
pBackground->setContentSize(CCSizeMake(640.0f, 960.0f));
this->addChild(pBackground);
this->setContentSize(pBackground->getContentSize());
Sprite* pBackgroundBoard = Sprite::create("popup/panel_popup_waiting.png");
pBackgroundBoard->setPosition(Point(320.0f, 480.0f));
pBackgroundBoard->setScaleY(0.7f);
this->addChild(pBackgroundBoard);
m_pLabelTitle = LabelBMFont::create(m_sTitle, "fonts/font_title-popup.fnt", 410.0f, TextHAlignment::CENTER);
m_pLabelTitle->setAnchorPoint(Point(0.5f, 0.5f));
m_pLabelTitle->setPosition(Point(320.0f, 485.0f));
this->addChild(m_pLabelTitle);
return true;
}
示例10: tableCellAtIndex
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);
//.........这里部分代码省略.........
示例11: initWin
bool EndGameNode::initWin()
{
if (!Node::init())
{
return false;
}
LevelConfig* pLevelConfig = &GameConfigManager::getInstance()->GetLevelConfig(m_sChapterId, m_iCurrentLevel);
m_iTotalBonusQuest = pLevelConfig->m_BonusQuestConfig.m_iBonusQuestCount;
LayerColor* pBackground = LayerColor::create(ccc4(7, 25, 44, 150));
pBackground->setContentSize(CCSizeMake(640.0f, 960.0f));
auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(true);
listener->onTouchBegan = [](Touch* touch, Event* event) { return true; };
EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, pBackground);
this->addChild(pBackground);
this->setContentSize(pBackground->getContentSize());
//m_pSpriteBatchNode = SpriteBatchNode::create("Target-End-Game/TargetEndgame.pvr.ccz");
//SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Target-End-Game/TargetEndgame.plist");
//this->addChild(m_pSpriteBatchNode);
Sprite* pBackgroundBoard = Sprite::create("Target-End-Game/panel-level_popup.png");
pBackgroundBoard->setPosition(Point(320.0f, 610.0f));
this->addChild(pBackgroundBoard);
m_pStarAndBonusQuestNode = Node::create();
this->addChild(m_pStarAndBonusQuestNode);
this->generateLayoutStartAndBonusQuest();
Sprite* pCompletedImage = Sprite::create("Target-End-Game/text_level_completed.png");
pCompletedImage->setPosition(Point(320.0f, 654.0f));
this->addChild(pCompletedImage);
FlashCardNode* pFlashCard = FlashCardNode::createLayout(m_mainWord);
pFlashCard->setPosition(70.0f, 200.0f);
pFlashCard->setScale(0.52f);
this->addChild(pFlashCard);
char sLevel[20];
int iCalLevel = GameConfigManager::getInstance()->CountLevelOfPreviousChapters(m_sChapterId);
sprintf(sLevel, "Level %d", m_iCurrentLevel + iCalLevel);
LabelBMFont *pLabelLevel = LabelBMFont::create(sLevel, "fonts/font-bechic.fnt");
pLabelLevel->setAnchorPoint(Point(0.5f, 0.5f));
pLabelLevel->setPosition(Point(320.0f, 870.0f));
this->addChild(pLabelLevel);
LabelBMFont *pLabelScore = LabelBMFont::create("SCORE:", "fonts/font_score.fnt");
pLabelScore->setAnchorPoint(Point(0.5f, 0.5f));
pLabelScore->setPosition(Point(474.0f, 525.0f));
this->addChild(pLabelScore);
LabelBMFont *pLabelNumScore = LabelBMFont::create(formatNumber(m_iScore).getCString(), "fonts/font_score.fnt");
pLabelNumScore->setAnchorPoint(Point(0.5f, 0.5f));
pLabelNumScore->setPosition(Point(474.0f, 480.0f));
pLabelNumScore->setScale(1.4f);
this->addChild(pLabelNumScore);
Sprite* pButtonNextGameSprite = Sprite::create("Target-End-Game/btn_next.png");
ButtonNode* buttonNextNode = ButtonNode::createButtonSprite(pButtonNextGameSprite, CC_CALLBACK_1(EndGameNode::menuNextLevelCallBack, this));
buttonNextNode->setPosition(Point(425.0f, 279.0f));
Sprite* pButtonReplayGameSprite = Sprite::create("Target-End-Game/btn_replay.png");
ButtonNode* buttonReplayNode = ButtonNode::createButtonSprite(pButtonReplayGameSprite, CC_CALLBACK_1(EndGameNode::menuRetryLevelWinCallBack, this));
buttonReplayNode->setPosition(Point(225.0f, 279.0f));
Sprite* pButtonCloseSprite = Sprite::create("Target-End-Game/btn_close.png");
ButtonNode* buttonCloseNode = ButtonNode::createButtonSprite(pButtonCloseSprite, CC_CALLBACK_1(EndGameNode::menuCloseWinCallBack, this));
buttonCloseNode->setPosition(Point(572.0f, 894.0f));
ButtonManagerNode* pButtonManagerNode = ButtonManagerNode::create();
pButtonManagerNode->addButtonNode(buttonNextNode);
pButtonManagerNode->addButtonNode(buttonCloseNode);
pButtonManagerNode->addButtonNode(buttonReplayNode);
this->addChild(pButtonManagerNode);
m_levelInfo = LevelTable::getInstance()->getLevel(m_sChapterId, m_iCurrentLevel);
m_chapterInfo = ChapterTable::getInstance()->getChapterInfo(m_sChapterId);
if (m_levelInfo.bIsUnlock == false)
{
m_chapterInfo.iTotalLevelUnlock++;
UserInfo userInfo = UserTable::getInstance()->getUserInfo();
userInfo.sCurrentChapterId = m_levelInfo.sChapterId;
userInfo.iCurrentLevel = m_levelInfo.iLevel + 1;
// Unlock chapter
WordlMapConfig worldMapConfig = GameConfigManager::getInstance()->GetWordlMapConfig();
int iIndexCurrentChapter = worldMapConfig.m_WorlMapChapterConfigMap[m_levelInfo.sChapterId];
WordlMapConfig::WordMapChapterConfig worldMapChapterConfig = worldMapConfig.m_WorlMapChapterConfigs[iIndexCurrentChapter];
if (m_iCurrentLevel >= worldMapChapterConfig.m_iTotalevel)
{
//userInfo.iCurrentLevel = worldMapChapterConfig.m_iTotalevel;
// Create data for new chapter
std::string sNextChapterID;
if ( GameConfigManager::getInstance()->GetNextChapterID(worldMapChapterConfig.m_sChapterId, sNextChapterID))
//.........这里部分代码省略.........
示例12: initLose
bool EndGameNode::initLose()
{
if (!Node::init())
{
return false;
}
LayerColor* pBackground = LayerColor::create(ccc4(7, 25, 44, 150));
pBackground->setContentSize(CCSizeMake(640.0f, 960.0f));
auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(true);
listener->onTouchBegan = [](Touch* touch, Event* event) { return true; };
EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, pBackground);
this->addChild(pBackground);
this->setContentSize(pBackground->getContentSize());
//m_pSpriteBatchNode = SpriteBatchNode::create("Target-End-Game/TargetEndgame.pvr.ccz");
//SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Target-End-Game/TargetEndgame.plist");
//this->addChild(m_pSpriteBatchNode);
Sprite* pBackgroundBoard = Sprite::create("Target-End-Game/panel-level_popup.png");
pBackgroundBoard->setPosition(Point(320.0f, 610.0f));
this->addChild(pBackgroundBoard);
Sprite* pLevelFailImage3 = Sprite::create("Target-End-Game/text_level_fail.png");
pLevelFailImage3->setPosition(Point(320.0f, 750.0f));
this->addChild(pLevelFailImage3);
Sprite* pIconBoosterLock1 = Sprite::create("Target-End-Game/lock-icon-powerup.png");
pIconBoosterLock1->setPosition(Point(220.0f, 415.0f));
this->addChild(pIconBoosterLock1);
Sprite* pIconBoosterLock2 = Sprite::create("Target-End-Game/lock-icon-powerup.png");
pIconBoosterLock2->setPosition(Point(320.0f, 415.0f));
this->addChild(pIconBoosterLock2);
Sprite* pIconBoosterLock3 = Sprite::create("Target-End-Game/lock-icon-powerup.png");
pIconBoosterLock3->setPosition(Point(420.0f, 415.0f));
this->addChild(pIconBoosterLock3);
FlashCardNode* pFlashCard = FlashCardNode::createLayout(m_mainWord);
pFlashCard->setPosition(70.0f, 285.0f);
pFlashCard->setScale(0.52f);
this->addChild(pFlashCard);
char sLevel[20];
int iCalLevel = GameConfigManager::getInstance()->CountLevelOfPreviousChapters(m_sChapterId);
sprintf(sLevel, "Level %d", m_iCurrentLevel + iCalLevel);
LabelBMFont *pLabelLevel = LabelBMFont::create(sLevel, "fonts/font-bechic.fnt");
pLabelLevel->setAnchorPoint(Point(0.5f, 0.5f));
pLabelLevel->setPosition(Point(320.0f, 870.0f));
this->addChild(pLabelLevel);
LabelBMFont *pLabelScore = LabelBMFont::create("SCORE:", "fonts/font_score.fnt");
pLabelScore->setAnchorPoint(Point(0.5f, 0.5f));
pLabelScore->setPosition(Point(474.0f, 630.0f));
this->addChild(pLabelScore);
LabelBMFont *pLabelNumScore = LabelBMFont::create(formatNumber(m_iScore).getCString(), "fonts/font_score.fnt");
pLabelNumScore->setAnchorPoint(Point(0.5f, 0.5f));
pLabelNumScore->setPosition(Point(474.0f, 585.0f));
pLabelNumScore->setScale(1.4f);
this->addChild(pLabelNumScore);
LeaderBoardtNode* pLeaderBoard = LeaderBoardtNode::createLayout(m_iCurrentLevel, m_sChapterId);
pLeaderBoard->setPosition(Point(320.0f, 114.0f));
this->addChild(pLeaderBoard);
Sprite* pButtonPlayGameSprite = Sprite::create("Target-End-Game/btn_replay.png");
ButtonNode* buttonPlayNode = ButtonNode::createButtonSprite(pButtonPlayGameSprite, CC_CALLBACK_1(EndGameNode::menuRetryLevelLoseCallBack, this));
buttonPlayNode->setPosition(Point(320.0f, 279.0f));
Sprite* pButtonCloseSprite = Sprite::create("Target-End-Game/btn_close.png");
ButtonNode* buttonCloseNode = ButtonNode::createButtonSprite(pButtonCloseSprite, CC_CALLBACK_1(EndGameNode::menuCloseLoseCallBack, this));
buttonCloseNode->setPosition(Point(572.0f, 894.0f));
ButtonManagerNode* pButtonManagerNode = ButtonManagerNode::create();
pButtonManagerNode->addButtonNode(buttonPlayNode);
pButtonManagerNode->addButtonNode(buttonCloseNode);
this->addChild(pButtonManagerNode);
return true;
}
示例13: JuegoTerminado
void Akuerdate::JuegoTerminado(){
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("ganar.mp3");
escuchadores = false;
juegoTerminado = true;
LayerColor *lyConseguido = LayerColor::create(Color4B(124,180,224,200));
lyConseguido->setPosition(cuadroJuego->getPosition());
lyConseguido->setContentSize(cuadroJuego->getContentSize());
lyConseguido->setLocalZOrder(20);
addChild(lyConseguido);
Sprite *foco = Sprite::create("preguntator_focoLuz.png");
foco->setScaleX(escalaAlta);
foco->setScaleY(0);
foco->setScaleZ(escalaAlta);
foco->setAnchorPoint(Vec2(0.5,1));
foco->setPosition(lyConseguido->getContentSize().width/2,lyConseguido->getContentSize().height);
lyConseguido->addChild(foco);
//animacion foco
ScaleTo *aniFoco = ScaleTo::create(0.7, escalaAlta);
foco->runAction(aniFoco);
__String *txtConsegido = __String::createWithFormat("%s %s",LanguageManager::getInstance()->getString("JUEGO_TX_FINAL_EXITO_2").c_str(),sNombreProfesion->getCString());
CCLabelTTF *txConseguido = CCLabelTTF::create(txtConsegido->getCString(), "HVD_Comic_Serif_Pro.ttf",120*escala,Size((visibleSize.width),(220*escala)*2), TextHAlignment::CENTER);
txConseguido->setColor(Color3B(25,78,121));
txConseguido->setVerticalAlignment(TextVAlignment::CENTER);
txConseguido->setAnchorPoint(Vec2(0.5,1));
txConseguido->setPosition(lyConseguido->getContentSize().width/2,visibleSize.height+(280*escala));
lyConseguido->addChild(txConseguido);
//animacion textoConsegido
MoveTo *aniTxConseguido = MoveTo::create(0.3, Vec2(lyConseguido->getContentSize().width/2,(lyConseguido->getContentSize().height)));
txConseguido->runAction(aniTxConseguido);
Sprite *pizzarra = Sprite::create("pizzarra_final_tiempo.png");
pizzarra->setScale(escalaAlta);
pizzarra->setAnchorPoint(Vec2(0.5,1));
pizzarra->setPosition(visibleSize.width,(lyConseguido->getContentSize().height)-(txConseguido->getContentSize().height));
lyConseguido->addChild(pizzarra);
CCLabelTTF *nAciertosPizarra = CCLabelTTF::create(reloj->getString(), "HVD_Comic_Serif_Pro.ttf",200,pizzarra->getContentSize(), TextHAlignment::CENTER);
nAciertosPizarra->setColor(Color3B(255,255,255));
nAciertosPizarra->setVerticalAlignment(TextVAlignment::CENTER);
nAciertosPizarra->setAnchorPoint(Vec2(0,0));
nAciertosPizarra->setPosition(0,0);
pizzarra->addChild(nAciertosPizarra);
//animacion pizzara
MoveTo *aniPizzarra = MoveTo::create(0.3, Vec2(lyConseguido->getContentSize().width/2,pizzarra->getPositionY()));
pizzarra->runAction(aniPizzarra);
CGestorRecursos *gRecursos = new CGestorRecursos();
CRecurso *recursoAleatorio = gRecursos->obtenerRecursoBloqueadoAleatorio();
if(recursoAleatorio!=NULL){
gRecursos->quitarRecursoBloqueado(recursoAleatorio);
Sprite *txPremio = Sprite::create("preguntator_finjuego_texto_inferior.png");
txPremio->setScale(escalaAlta);
txPremio->setAnchorPoint(Vec2(0.5,0));
txPremio->setPosition(foco->getPositionX(),foco->getPositionY()-(foco->getContentSize().height*escalaAlta));
txPremio->setOpacity(0);
lyConseguido->addChild(txPremio);
//animacion txPremio
Sequence *aniPremio1 = Sequence::create(DelayTime::create(0.7),FadeIn::create(1),NULL);
txPremio->runAction(aniPremio1);
Sprite *premio = Sprite::create(recursoAleatorio->uri->getCString());
float escalaPremio = ((pizzarra->getContentSize().height*pizzarra->getScale())/2)/premio->getContentSize().height;
float escalaPremioAncha = ((pizzarra->getContentSize().width*pizzarra->getScale()))/premio->getContentSize().width;
if(escalaPremioAncha<escalaPremio)
escalaPremio = escalaPremioAncha;
premio->setScale(escalaPremio);
premio->setAnchorPoint(Vec2(0.5,0));
premio->setPosition(txPremio->getPositionX(),txPremio->getPositionY()+(20*escalaPremio)+(txPremio->getContentSize().height*txPremio->getScaleY()));
premio->setOpacity(0);
//nuevo
if(recursoAleatorio->tipoRecurso->getValue()!=Configuracion::rcsTipoOjos&&recursoAleatorio->tipoRecurso->getValue()!=Configuracion::rcsTipoAccesorio&&recursoAleatorio->tipoRecurso->getValue()!=Configuracion::rcsTipoDientes&&recursoAleatorio->tipoRecurso->getValue()!=Configuracion::rcsTipoColor)
premio->runAction(TintTo::create(0,0,0,0));
lyConseguido->addChild(premio);
string textoTraducido1 = LanguageManager::getInstance()->getString("kitDe");
string keyTexto2 = __String::createWithFormat("tipoRecurso%i",recursoAleatorio->tipoRecurso->getValue())->getCString();
string textoTraducido2 = LanguageManager::getInstance()->getString(keyTexto2);
string textoFinal = __String::createWithFormat("%s %s",textoTraducido1.c_str(),textoTraducido2.c_str())->getCString();
CCLabelTTF *nAciertosPizarra = CCLabelTTF::create(textoFinal, "HVD_Comic_Serif_Pro.ttf",60,Size(lyConseguido->getContentSize().width,txPremio->getContentSize().height), TextHAlignment::CENTER);
nAciertosPizarra->setColor(Color3B(229,57,57));
nAciertosPizarra->setVerticalAlignment(TextVAlignment::BOTTOM);
nAciertosPizarra->setAnchorPoint(Vec2(0.5,0));
nAciertosPizarra->setPosition(txPremio->getContentSize().width/2,80);
nAciertosPizarra->setOpacity(0);
txPremio->addChild(nAciertosPizarra);
//.........这里部分代码省略.........