【发布时间】:2017-05-07 13:16:58
【问题描述】:
目前,我正在尝试在 cocos2dx 中显示 Menu(MenuItemImage) 但它没有显示出来。 Sprite 正常显示。我用谷歌搜索但没有解决方案。我很想从你那里得到一些提示或例子!
bool GameLayer::init(int level)
{
if (!Layer::init())
return false;
auto moreButton = MenuItemImage::create("more.png","more.png",[](Ref*sender){});
moreButton->setPosition(Vec2(WINSIZE.width /2.0,WINSIZE.height / 2.0));
this->addChild(moreButton, ZOrder::Enemy);
auto menu = Menu::create(moreButton, NULL);
this->addChild(menu);
menu->setPosition(WINSIZE.width / 2.0, WINSIZE.height / 2.0);
initBackground();
return true;
}
void GameLayer::initBackground()
{
auto bgForCharacter = Sprite::create("Background1.png");
bgForCharacter->setAnchorPoint(Point(0, 1));
bgForCharacter->setPosition(Point(0, WINSIZE.height));
addChild(bgForCharacter, ZOrder::BgForCharacter);
auto bgForPuzzle = Sprite::create("Background2.png");
bgForPuzzle->setAnchorPoint(Point::ZERO);
bgForPuzzle->setPosition(Point::ZERO);
addChild(bgForPuzzle, ZOrder::BgForP);
//TODO
}
以下是在头类中。
enum ZOrder
{
BgForCharacter = 0,
BgForPuzzle,
Enemy,
EnemyHp,
Char,
CharHp,
Ball,
Level,
Result,
};
【问题讨论】:
-
WINSIZE的值是多少? -
它是“#define WINSIZE Director::getInstance()->getWinSize()”
标签: c++ cocos2d-x cocos2d-x-3.0