本文整理汇总了C++中CCMenu::getPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenu::getPositionX方法的具体用法?C++ CCMenu::getPositionX怎么用?C++ CCMenu::getPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenu
的用法示例。
在下文中一共展示了CCMenu::getPositionX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool GameSprite_Rice::init()
{
if (!CCSprite::init()) {
return false;
}
this->setContentSize(CCSize(500, 70));
addRiceTime = RICEADDTIME;
riceNum = 0;
nowTime = 0;
nowTime = this->getCurrentTime();
//字体背景.
CCMenuItemImage *labelBgSprite = CCMenuItemImage::create();
labelBgSprite->setNormalSpriteFrame(GameShare_Texture::sharedTexture()->GetSpriteFrameByCCRect(akoomenu_image, CCRect(1763, 255, 120, 49)));
labelBgSprite->setAnchorPoint(CCPointZero);
labelBgSprite->setPosition(CCPointZero);
labelBgSprite->setTag(Key_Add);
CCMenu* pMenu = CCMenu::create(labelBgSprite, NULL);
pMenu->setPosition(ccp(300,0));
pMenu->setTag(Key_Add);
this->addChild(pMenu);
//时间标签.
CCLabelTTF *timeLabel = CCLabelTTF::create("", "Arial", 20);
ccColor3B color = ccc3(95, 46, 33);
char strTime[32];
sprintf(strTime,"%d:%d%d",addRiceTime/60,addRiceTime%60/10,addRiceTime%60%10);
timeLabel->setColor(color);
timeLabel->setString(strTime);
timeLabel->setTag(Key_Time);
timeLabel->setPosition(ccp(pMenu->getPositionX()+40, pMenu->getPositionY()+20));
this->addChild(timeLabel);
//饭的背景
CCSprite *riceBgSprite = GameShare_Texture::sharedTexture()->GetSpriteByCCRect(akoomenu_image, CCRect(1, 1570, 278, 30));
riceBgSprite->setAnchorPoint(CCPointZero);
riceBgSprite->setPosition(ccp(0,5));
this->addChild(riceBgSprite);
this->schedule(schedule_selector(GameSprite_Rice::timeUpdate), 1.0);
return true;
}
示例2: CCDirectorGetWindowsSize
bool
MCSkillLayer::init()
{
if (MCBaseInfoLayer::init()) {
CCSize winSize = CCDirectorGetWindowsSize();
float contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
CCMenu *menu;
CCLabelTTF *label;
CCMenuItem *menuItem;
float fontSize = 24.0f / contentScaleFactor;
float offsetXLeft = 200 / contentScaleFactor;
content_.push_back(JsonBox::Value("name"));
content_.push_back(JsonBox::Value("releaseTime"));
content_.push_back(JsonBox::Value("activeTime"));
content_.push_back(JsonBox::Value("coldTime"));
content_.push_back(JsonBox::Value("consume"));
content_.push_back(JsonBox::Value("requiredProficiency"));
content_.push_back(JsonBox::Value("revise"));
content_.push_back(JsonBox::Value("count"));
content_.push_back(JsonBox::Value("effect"));
selectedSkill_ = NULL;
/* 技能种类 */
menu = CCMenu::create();
label = CCLabelTTF::create("剑", "", fontSize);
menuItem = CCMenuItemLabel::create(label,
this,
menu_selector(MCSkillLayer::selectSkillType));
menuItem->setTag(MCSwordSkill);
menu->addChild(menuItem);
label = CCLabelTTF::create("锤", "", fontSize);
menuItem = CCMenuItemLabel::create(label,
this,
menu_selector(MCSkillLayer::selectSkillType));
menuItem->setTag(MCHammerSkill);
menu->addChild(menuItem);
label = CCLabelTTF::create("斧", "", fontSize);
menuItem = CCMenuItemLabel::create(label,
this,
menu_selector(MCSkillLayer::selectSkillType));
menuItem->setTag(MCAxeSkill);
menu->addChild(menuItem);
label = CCLabelTTF::create("枪", "", fontSize);
menuItem = CCMenuItemLabel::create(label,
this,
menu_selector(MCSkillLayer::selectSkillType));
menuItem->setTag(MCSpearSkill);
menu->addChild(menuItem);
label = CCLabelTTF::create("弓", "", fontSize);
menuItem = CCMenuItemLabel::create(label,
this,
menu_selector(MCSkillLayer::selectSkillType));
menuItem->setTag(MCBowSkill);
menu->addChild(menuItem);
menu->alignItemsVerticallyWithPadding(4);
addChild(menu);
menu->setAnchorPoint(ccp(0, 0.5));
menu->setPosition(ccp(offsetXLeft, winSize.height / 2));
/* 技能表格 */
tableViewSize_ = CCSizeMake(180 / contentScaleFactor,
320 / contentScaleFactor);
tableView_ = CCTableView::create(this, tableViewSize_);
addChild(tableView_);
tableView_->setDirection(kCCScrollViewDirectionVertical);
tableView_->setDelegate(this);
tableView_->setVerticalFillOrder(kCCTableViewFillTopDown);
tableView_->setAnchorPoint(ccp(0, 0.5));
tableView_->setPosition(ccp(menu->getPositionX() + menuItem->getContentSize().width,
(winSize.height - tableViewSize_.height) / 2));
contentTableView_ = CCTableView::create(this, tableViewSize_);
addChild(contentTableView_);
contentTableView_->setDirection(kCCScrollViewDirectionVertical);
contentTableView_->setDelegate(this);
contentTableView_->setVerticalFillOrder(kCCTableViewFillTopDown);
contentTableView_->setAnchorPoint(ccp(0, 0.5));
contentTableView_->setPosition(ccp(tableView_->getPositionX() + tableViewSize_.width,
(winSize.height - tableViewSize_.height) / 2));
contentTableView_->setVisible(false);
icon_ = CCSprite::create();
addChild(icon_);
icon_->setAnchorPoint(ccp(1, 1));
icon_->setPosition(ccp(winSize.width - 64.0f / contentScaleFactor,
//.........这里部分代码省略.........
示例3: init
// on "init" you need to initialize your instance
bool TestAircraft::init()
{
if ( !CCLayer::init() )
{
return false;
}
// ------------
// init input manager
// ---------------
InputManager* input = InputManager::sharedInstance();
CCDirector::sharedDirector()->getKeypadDispatcher()->addDelegate(input);
// -------------
// init physics
// -----------
PhysicsManager::sharedInstance()->enableDebugDraw(true);
GB2ShapeCache::sharedGB2ShapeCache()->addShapesWithFile("png/physics.plist");
// step
schedule(schedule_selector(TestAircraft::stepForPhysicsManager));
// -----------------
// Init Audio
// ------------
SimpleAudioEngine::sharedEngine()->preloadEffect("wav/exploStd.wav");
// ------------
// Hero Aircraft
// -----------
Aircraft* hero = Aircraft::createHeroAircraft();
addChild(hero);
CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
hero->setPosition(screenSize.width/2, screenSize.height/2);
GameController::sharedInstance()->setPlayerAircraft(hero);
// ------------
// create menu
// -------------
CCMenu* menu = CCMenu::create();
// straight menu item
{
CCMenuItemFont* menuItem = CCMenuItemFont::create("straight", this, menu_selector(TestAircraft::menuItemCallback));
menu->addChild(menuItem);
}
// omni
{
CCMenuItemFont* menuItem = CCMenuItemFont::create("omni", this, menu_selector(TestAircraft::menuItemCallback));
menu->addChild(menuItem);
}
// ray gun
{
CCMenuItemFont* menuItem = CCMenuItemFont::create("ray gun", this, menu_selector(TestAircraft::menuItemCallback));
menu->addChild(menuItem);
}
// tank
{
CCMenuItemFont* menuItem = CCMenuItemFont::create("tank", this, menu_selector(TestAircraft::menuItemCallback));
menu->addChild(menuItem);
}
// boss00
{
CCMenuItemFont* menuItem = CCMenuItemFont::create("boss00", this, menu_selector(TestAircraft::menuItemCallback));
menu->addChild(menuItem);
}
// boss01
{
CCMenuItemFont* menuItem = CCMenuItemFont::create("boss01", this, menu_selector(TestAircraft::menuItemCallback));
menu->addChild(menuItem);
}
// hero
{
CCMenuItemFont* menuItem = CCMenuItemFont::create("hero", this, menu_selector(TestAircraft::menuItemCallback));
menu->addChild(menuItem);
}
menu->alignItemsVertically();
addChild(menu);
menu->setPositionX(menu->getPositionX() + 200);
return true;
}