本文整理汇总了C++中MenuItemFont::setAnchorPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItemFont::setAnchorPoint方法的具体用法?C++ MenuItemFont::setAnchorPoint怎么用?C++ MenuItemFont::setAnchorPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItemFont
的用法示例。
在下文中一共展示了MenuItemFont::setAnchorPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
MenuItemFont* pIncrease = MenuItemFont::create("increase 20",CC_CALLBACK_1(HelloWorld::increaseCallback,this));
pIncrease->setAnchorPoint(Vec2(0.0f,1.0f));
pIncrease->setPosition(0.0f,visibleSize.height - 0.0f);
MenuItemFont* pReduce = MenuItemFont::create("reduce 20",CC_CALLBACK_1(HelloWorld::reduceCallback,this));
pReduce->setAnchorPoint(Vec2(0.0f,1.0f));
pReduce->setPosition(0.0f,visibleSize.height - 40.0f);
MenuItemFont* pGoto = MenuItemFont::create("goto 100",CC_CALLBACK_1(HelloWorld::gotoCallback,this));
pGoto->setAnchorPoint(Vec2(0.0f,1.0f));
pGoto->setPosition(0.0f,visibleSize.height - 80.0f);
Menu* pMenu = Menu::create(pIncrease,pReduce,pGoto, NULL);
pMenu->setPosition(Vec2(0.0f,0.0f));
this->addChild(pMenu, 1);
LabelAtlas* pNumber = LabelAtlas::create("","number.png",55,84,'0');
pNumber->setAnchorPoint(Vec2(0.5f,0.5f));
pNumber->setPosition(Vec2(visibleSize.width/2.0f,
visibleSize.height/2.0f));
this->addChild(pNumber);
m_numberCount.setLabelAtlas(pNumber); //如果是从cocostudio导出的话请调用NumberCount::setTextAtlas
//将数字每一步的增量初始化为3
m_numberCount.setNumberDelta(3);
//将数字增加时间间隔设置为0.1秒
m_numberCount.setTimeDelta(0.1f);
//将数字初始化为100
m_numberCount.setNumber(100,false);
return true;
}
示例2: init
bool MDPauseMenu::init(MDPauseMenuInterfaz* target)
{
if (CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)) )
{
mTarget = target;
Size visibleSize = Director::getInstance()->getVisibleSize();
// Menu items
MenuItemFont *btResume = MenuItemFont::create("Resume",
this,
menu_selector(MDPauseMenu::resumeGame));
btResume->setColor(ccc3(255, 255, 255));
btResume->setAnchorPoint(ccp(0.5, 1));
btResume->setPosition(ccp(0, 0));
MenuItemFont *btRetry = MenuItemFont::create("Retry",
this,
menu_selector(MDPauseMenu::retryGame));
btRetry->setColor(ccc3(255, 255, 255));
btRetry->setAnchorPoint(ccp(0.5, 1));
btRetry->setPosition(ccp(0, btResume->getPosition().y - btResume->getContentSize().height - MENU_ITEMS_SPACING));
MenuItemFont *btExit = MenuItemFont::create("Exit",
this,
menu_selector(MDPauseMenu::quitGame));
btExit->setColor(ccc3(255, 255, 255));
btExit->setAnchorPoint(ccp(0.5, 1));
btExit->setPosition(ccp(0, btRetry->getPosition().y - btRetry->getContentSize().height - MENU_ITEMS_SPACING));
// Menu
Menu *menu = Menu::create(btResume, btRetry, btExit, NULL);
menu->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
addChild(menu);
return true;
}
return false;
}
示例3: okCallback
void HelloWorld::okCallback(Ref* pSender)
{
if(!m_bg)
{
m_runLayer = Layer::create();
this->addChild(m_runLayer);
int dirSel = m_dirSelItem->getSelectedIndex();
switch (dirSel)
{
case 0:
m_bg = ScrollingBackground::create(ScrollDirection::SD_RIGHT_TO_LEFT);
m_direction = ScrollDirection::SD_RIGHT_TO_LEFT;
break;
case 1:
m_bg = ScrollingBackground::create(ScrollDirection::SD_LEFT_TO_RIGHT);
m_direction = ScrollDirection::SD_LEFT_TO_RIGHT;
break;
case 2:
m_bg = ScrollingBackground::create(ScrollDirection::SD_TOP_TO_BOTTOM);
m_direction = ScrollDirection::SD_TOP_TO_BOTTOM;
break;
case 3:
m_bg = ScrollingBackground::create(ScrollDirection::SD_BOTTOM_TO_TOP);
m_direction = ScrollDirection::SD_BOTTOM_TO_TOP;
break;
default:
break;
}
m_runLayer->addChild(m_bg,1);
for (int i = 1; i < 5; i++)
{
addBgSprite(i);
}
/*
//当有一个背景精灵彻底离开屏幕的时候的消息,两种方式
if(m_modeSelItem->getSelectedIndex()==0)
m_bg->setBgChangeEventListener(this,bgSpriteChangeEvent(HelloWorld::loopBgChangeCallback)); //循环模式
else
m_bg->setBgChangeEventListener(this,bgSpriteChangeEvent(HelloWorld::dropBgChangeCallback)); //丢弃模式
*/
//当有一个背景精灵彻底离开屏幕的时候的消息,两种方式
if(m_modeSelItem->getSelectedIndex()==0)
m_bg->setBgChangeEventListener(CC_CALLBACK_3(HelloWorld::loopBgChangeCallback,this)); //循环模式
else
m_bg->setBgChangeEventListener(CC_CALLBACK_3(HelloWorld::dropBgChangeCallback,this)); //丢弃模式
/*
//当背景精灵移动时候的消息,两种方式
m_bg->setBgMoveEventListener(this,bgSpriteMoveEvent(HelloWorld::bgMoveCallback));
*/
//当背景精灵移动时候的消息,两种方式
m_bg->setBgMoveEventListener(CC_CALLBACK_2(HelloWorld::bgMoveCallback,this));
m_velocity = 300.0f;
m_bgSprite = m_bg->getCurBgSprite();
m_bg->beginContinuousScroll(m_velocity);
//一个跟随背景移动的物体
m_pItem = Sprite::create("item.png");
m_pItem->setAnchorPoint(Vec2(0.5f,0.5f));
m_pItem->setPosition(Vec2(0.0f,0.0f));
m_runLayer->addChild(m_pItem,2);
//pItem锚点一直都是(0.5,0.5),坐标一直是(0.0,0.0),注意看当画面切换的时候他会出现在哪里
//背景精灵精灵的锚点不同,会影响pItem的位置
m_pItem->setPosition(m_bg->getCurBgSprite()->getPosition());
/*下面的是一些菜单的设置,不看也可以*/
Size visibleSize = Director::getInstance()->getVisibleSize();
//返回按钮
MenuItemFont* back = MenuItemFont::create("back",CC_CALLBACK_1(HelloWorld::backCallback,this));
back->setAnchorPoint(Vec2(1.0f,1.0f));
back->setPosition(Vec2(visibleSize.width/2.0f,visibleSize.height/2.0f));
//设置相反速度的按钮
MenuItemFont* reverse = MenuItemFont::create("reverse",CC_CALLBACK_1(HelloWorld::reverseCallback,this));
//暂停
MenuItemToggle* pause = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::pauseCallback,this),
MenuItemFont::create("pause"),
MenuItemFont::create("resume"),
NULL);
pause->setPosition(Vec2(0.0f,50.0f));
//上一个画面
MenuItemImage* lastBg = MenuItemImage::create("lastBgNor.png","lastBgCli.png","",CC_CALLBACK_1(HelloWorld::nextBgCallback,this));
lastBg->setTag(0);
lastBg->setAnchorPoint(Vec2(0.0f,0.5f));
lastBg->setPosition(Vec2(-visibleSize.width/2.0f,0.0f));
//下一个画面
//.........这里部分代码省略.........