本文整理汇总了C++中MenuItemSprite::getBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItemSprite::getBoundingBox方法的具体用法?C++ MenuItemSprite::getBoundingBox怎么用?C++ MenuItemSprite::getBoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItemSprite
的用法示例。
在下文中一共展示了MenuItemSprite::getBoundingBox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool HomeLayer::init(){
bool isDay = UserDefault::getInstance()->getBoolForKey(DayTime, true);
string file = "modify/day_bg.png";
if (isDay == false) {
file = string("modify/night_bg.png");
}
if (GameLayerBase::initWithBgFileName(file.c_str())) {
Sprite* centerTitle = Sprite::create("modify/title.png");
centerTitle->setAnchorPoint(Vec2(0.5, 1.0));
centerTitle->setPosition(STVisibleRect::getCenterOfScene().x, STVisibleRect::getPointOfSceneLeftUp().y - 60);
addChild(centerTitle, 1);
//
// TableViewTest* pLayer = TableViewTest::create();
// this->addChild(pLayer, 2);
MenuItemSprite* lightBtn = CocosHelper::menuItemSprite("modify/night.png");
MenuItemSprite* settingBtn = CocosHelper::menuItemSprite("modify/setting.png");
MenuItemSprite* vedioBtn = CocosHelper::menuItemSprite("modify/video.png");
string soundFile = "modify/sound1.png";
if (!SoundPlayer::getInstance()->isMusicOpen()) {
soundFile = "modify/sound2.png";
}
MenuItemSprite* soundBtn = CocosHelper::menuItemSprite(soundFile.c_str());
MenuItemSprite* shareBtn = CocosHelper::menuItemSprite("modify/share.png");
lightBtn->setTag(kLightBtnTag);
settingBtn->setTag(kSettingBtnTag);
vedioBtn->setTag(kVedioBtnTag);
soundBtn->setTag(kSoundBtnTag);
shareBtn->setTag(kShareBtnTag);
lightBtn->setAnchorPoint(Vec2(0, 0));
settingBtn->setAnchorPoint(Vec2(1.0, 0));
vedioBtn->setAnchorPoint(Vec2(0.5, 0));
soundBtn->setAnchorPoint(Vec2(1.0, 0));
shareBtn->setAnchorPoint(Vec2(1.0, 0));
lightBtn->setPosition(Vec2(STVisibleRect::getOriginalPoint().x + 15, 60*0.618+STVisibleRect::getOriginalPoint().y));
settingBtn->setPosition(Vec2(STVisibleRect::getPointOfSceneRightBottom().x - 15, 60*0.618 + STVisibleRect::getOriginalPoint().y));
vedioBtn->setPosition(Vec2(STVisibleRect::getCenterOfScene().x, lightBtn->getBoundingBox().getMaxY() + 15));
soundBtn->setPosition(settingBtn->getPosition()+Vec2(15, 0));
shareBtn->setPosition(settingBtn->getPosition()+Vec2(15, 0));
lightBtn->setCallback(CC_CALLBACK_1(HomeLayer::onClickedMenuItems, this));
settingBtn->setCallback(CC_CALLBACK_1(HomeLayer::onClickedMenuItems, this));
vedioBtn->setCallback(CC_CALLBACK_1(HomeLayer::onClickedMenuItems, this));
Menu* pBtns = Menu::create(lightBtn, settingBtn, vedioBtn, NULL);
pBtns->setAnchorPoint(Vec2(0, 0));
pBtns->setPosition(Vec2(0, 0));
addChild(pBtns, 2);
float maxHeight = centerTitle->getBoundingBox().getMidY() - vedioBtn->getBoundingBox().getMaxY();
log("the max height is %.2f", maxHeight);
float tableHeight = maxHeight - 100*1.618;
float tableWidth = STVisibleRect::getGlvisibleSize().width - 200*0.618;
log("the tablewidth is %.2f, and the tableheight is %.2f", tableWidth, tableHeight);
int w = (int)tableWidth;
int h = (int)tableHeight;
TableViewTest* pLayer = TableViewTest::create(Size(w, h));
pLayer->setPosition(Vec2(100*0.618 + STVisibleRect::getOriginalPoint().x, vedioBtn->getBoundingBox().getMaxY() + 100*0.618));
addChild(pLayer, 10);
pLayer->setDelegate(this);
return true;
}
return false;
}