目前,我试图在cocos2dx中显示菜单(MenuItemImage),但它不显示。雪碧正常显示。我搜索周围,但没有解决方案。我很乐意提供一些提示或例子!无法在cocos2dx中显示菜单MenuItemImage
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'的价值是什么? – Aryan
这是“#define WINSIZE Director :: getInstance() - > getWinSize()” – user3264924