当前位置: 首页>>代码示例>>C++>>正文


C++ LayerColor::runAction方法代码示例

本文整理汇总了C++中LayerColor::runAction方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerColor::runAction方法的具体用法?C++ LayerColor::runAction怎么用?C++ LayerColor::runAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LayerColor的用法示例。


在下文中一共展示了LayerColor::runAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onEnter

void GameOverDialog::onEnter() {
    Node::onEnter();

    Size visibleSize = Director::getInstance()->getVisibleSize();
    // this->setContentSize(visibleSize);

    LayerColor *background = LayerColor::create(Color4B(0, 0, 0, 178));
    this->addChild(background);
    // background->setContentSize(visibleSize);

    // TODO: We should decide winner in the game scene
    std::string filename = _playerLifePoint == _opponentLifePoint
                               ? "labelDraw.png"
                               : (_playerLifePoint > _opponentLifePoint ? "labelYouWin.png" : "labelYouLose.png");
    Sprite *title = Sprite::create(filename);
    title->setAnchorPoint(Vec2::ANCHOR_MIDDLE_TOP);
    title->setPosition(Vec2(visibleSize.width * 0.5f, visibleSize.height * 0.9f));

    std::stringstream ss;
    ss << _playerLifePoint * 100 / INITIAL_PLAYER_LIFE << "% - " << _opponentLifePoint * 100 / INITIAL_PLAYER_LIFE
       << "%";
    // TODO: Do not use magic number
    auto scoreLabel = ui::Text::create(ss.str(), FONT_DIGIT, 96);
    scoreLabel->setAnchorPoint(Vec2(0.5f, 0.5f));
    scoreLabel->setPosition(Vec2(visibleSize.width * 0.5f, visibleSize.height * 0.5f));
    scoreLabel->setColor(Color3B::WHITE);

    _button = ui::Button::create();
    _button->loadTextures("buttonOk.png", "buttonOkPressed.png");
    _button->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM);
    _button->setPosition(Vec2(visibleSize.width * 0.5f, visibleSize.height * 0.1f));
    _button->addTouchEventListener(CC_CALLBACK_2(GameOverDialog::buttonPressed, this));

    this->addChild(title);
    this->addChild(scoreLabel);
    this->addChild(_button);

    auto action = cocos2d::FadeTo::create(0.1, 178);
    background->setOpacity(0);
    background->runAction(action);
}
开发者ID:haruki-nakano,项目名称:Yuzu,代码行数:41,代码来源:GameOverDialog.cpp


注:本文中的LayerColor::runAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。