Пример #1
0
void GameScene::createMenuButtons() {

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    mTimerLabel = Label::createWithSystemFont("0.0", "Heiti TC", 50,
                                              Size::ZERO, TextHAlignment::CENTER,TextVAlignment::CENTER);
#else
    TTFConfig config("fonts/Montserra.ttf",50);
    mTimerLabel = Label::createWithTTF(config,"0.0");
#endif
    
    addChild(mTimerLabel,1000);
    mTimerLabel->setPosition(VisibleRect::center().x, VisibleRect::top().y + 50);
    
    mBackMenu = MenuItemImage::create("images/menu_icon.png", "images/menu_icon.png", [&](Ref*) {
        mBackMenu->runAction(Sequence::create(ScaleTo::create(0.1, 0.5),ScaleTo::create(0.1, 0.4), NULL));
        
        showHideMenu(true);
        this->runAction(Sequence::create(DelayTime::create(0.2), CallFunc::create([this]{
            toMainMenu();
        }), NULL));
    });

    mRestartMenu = MenuItemImage::create("images/restart_icon.png", "images/restart_icon.png", [&](Ref*) {
        mRestartMenu->runAction(Sequence::create(ScaleTo::create(0.1, 0.6),ScaleTo::create(0.1, 0.5), NULL));
        
        showHideMenu(true);
        this->runAction(Sequence::create(DelayTime::create(0.2), CallFunc::create([this]{
            mGame->enableGame(false);
            mGame->enableGame(true);
        }), NULL));
    });
    
    mBackMenu->setColor(Color3B(200,200,200));
    mRestartMenu->setColor(Color3B(200,200,200));
    mTimerLabel->setColor(Color3B(200,200,200));
    
    mBackMenu->setPosition(50, VisibleRect::top().y + 50);
    mRestartMenu->setPosition(VisibleRect::right().x - 50, VisibleRect::top().y + 50);
    
    mBackMenu->setScale(0.4);
    mRestartMenu->setScale(0.5);

    auto menu = Menu::create(mBackMenu,mRestartMenu, NULL);
    menu->setPosition(Vec2::ZERO);
    addChild(menu,1000);
}
Пример #2
0
void GameScene::onWinGame() {
    enableGame(false);
    if(mTimerLabel->getPositionY() < VisibleRect::top().y) {
        showHideMenu(true);
    }
    this->runAction(Sequence::create(DelayTime::create(0.3), CallFunc::create([this]{
        toMainMenu();
    }), NULL));
}
Пример #3
0
void GameScene::onEndTouch(const cocos2d::Vec2& pos) {
    
    if(pos.y > VisibleRect::top().y * 0.3 && pos.y < VisibleRect::top().y - 100) {
        showHideMenu();
    } else {
        if(pos.x < VisibleRect::center().x) {
            mLeftButton->setOpacity(TRANSPARENT_BUTTON);
            mRightButton->setOpacity(TRANSPARENT_BUTTON);
            mGame->mMoveLeft = false;
            mGame->mMoveRight = false;
        } else {
            mCanJump = true;
            mJumpButton->setOpacity(TRANSPARENT_BUTTON);
        }
    }
}
Пример #4
0
RazorMainMenu::RazorMainMenu(const IRazorPanelPluginStartupInfo &startupInfo):
    QObject(),
    IRazorPanelPlugin(startupInfo),
    mMenu(0),
    mShortcut(0),
    mLockCascadeChanges(false)
{
    mButton.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);

    connect(&mButton, SIGNAL(clicked()), this, SLOT(showMenu()));

    mPowerManager = new PowerManager(this);
    mScreenSaver = new ScreenSaver(this);

    settingsChanged();

    connect(mShortcut, SIGNAL(activated()), this, SLOT(showHideMenu()));
    connect(mShortcut, SIGNAL(shortcutChanged(QString,QString)), this, SLOT(shortcutChanged(QString,QString)));
}
Пример #5
0
RazorMainMenu::RazorMainMenu(const RazorPanelPluginStartInfo* startInfo, QWidget* parent):
    RazorPanelPlugin(startInfo, parent),
    mMenu(0)
{
    setObjectName("MainMenu");

    layout()->setAlignment(Qt::AlignCenter);
    mButton.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    mButton.setObjectName("Button");

    connect(&mButton, SIGNAL(clicked()), this, SLOT(showMenu()));
    connect(panel(), SIGNAL(panelRealigned()), this, SLOT(realign()));

    mPowerManager = new PowerManager(this);
    mScreenSaver = new ScreenSaver(this);

    mShortcut = new QxtGlobalShortcut(this);
    connect(mShortcut, SIGNAL(activated()), this, SLOT(showHideMenu()));

    addWidget(&mButton);
    settingsChanged();
}