定位菜单项无法正常工作

时间:2014-05-26 01:55:48

标签: c++ cocos2d-x

我正在尝试创建一个带有2个按钮的菜单,但是当我尝试定位按钮时,按钮设置的x和y位置看起来不正确。例如,当我尝试将它们放在屏幕中间时,它们出现在屏幕的右上角:

这是我的代码:

messageBoxBg = Sprite::create("001_CAIXA.png");
    messageBoxBg->setPosition(Point(visibleSize.width*.5, visibleSize.height*.5));
    this->addChild(messageBoxBg,20);

    okButton = MenuItemImage::create("002_Botao_off.png", "002_Botao_on.png", CC_CALLBACK_1(HelloWorld::okClicked, this));
    okButton->setPosition(Point(visibleSize.width*.1, visibleSize.height/5));

    closeButton = MenuItemImage::create("001_2CAIXA.png", "001_3CAIXA.png", CC_CALLBACK_1(HelloWorld::okClicked, this));
    closeButton->setPosition(Point(visibleSize.width*.1, visibleSize.height/9));

    msgMenu = Menu::create(okButton, closeButton, NULL);
    messageBoxBg->addChild(msgMenu,20);

我想将okButton定位在messageBoxBg的botton中间,并将messageBB的右上角的closeButton定位。

0 个答案:

没有答案