无法在cocos2dx中显示Menu MenuItemImage

时间:2017-05-07 13:16:58

标签: c++ cocos2d-x cocos2d-x-3.0

目前,我尝试在cocos2dx中显示菜单(MenuItemImage),但它并没有显示出来。精灵正常显示。我用Google搜索但没有解决方案。我很乐意为您提供一些提示或示例!

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,
    };

0 个答案:

没有答案
相关问题