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


C++ MenuItemSprite::getPosition方法代码示例

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


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

示例1: init

bool HomeLayer::init(){
    bool isDay = UserDefault::getInstance()->getBoolForKey(DayTime, true);
    string file = "modify/day_bg.png";
    if (isDay == false) {
        file = string("modify/night_bg.png");
    }
    if (GameLayerBase::initWithBgFileName(file.c_str())) {
        
        Sprite* centerTitle = Sprite::create("modify/title.png");
        centerTitle->setAnchorPoint(Vec2(0.5, 1.0));
        centerTitle->setPosition(STVisibleRect::getCenterOfScene().x, STVisibleRect::getPointOfSceneLeftUp().y - 60);
        addChild(centerTitle, 1);
  
//
//        TableViewTest* pLayer = TableViewTest::create();
//        this->addChild(pLayer, 2);
        MenuItemSprite* lightBtn = CocosHelper::menuItemSprite("modify/night.png");
        MenuItemSprite* settingBtn = CocosHelper::menuItemSprite("modify/setting.png");
        MenuItemSprite* vedioBtn = CocosHelper::menuItemSprite("modify/video.png");
        string soundFile = "modify/sound1.png";
        if (!SoundPlayer::getInstance()->isMusicOpen()) {
            soundFile = "modify/sound2.png";
        }
        MenuItemSprite* soundBtn = CocosHelper::menuItemSprite(soundFile.c_str());
        MenuItemSprite* shareBtn = CocosHelper::menuItemSprite("modify/share.png");

        lightBtn->setTag(kLightBtnTag);
        settingBtn->setTag(kSettingBtnTag);
        vedioBtn->setTag(kVedioBtnTag);
        soundBtn->setTag(kSoundBtnTag);
        shareBtn->setTag(kShareBtnTag);
        
        lightBtn->setAnchorPoint(Vec2(0, 0));
        settingBtn->setAnchorPoint(Vec2(1.0, 0));
        vedioBtn->setAnchorPoint(Vec2(0.5, 0));
        soundBtn->setAnchorPoint(Vec2(1.0, 0));
        shareBtn->setAnchorPoint(Vec2(1.0, 0));
        
        lightBtn->setPosition(Vec2(STVisibleRect::getOriginalPoint().x + 15, 60*0.618+STVisibleRect::getOriginalPoint().y));
        settingBtn->setPosition(Vec2(STVisibleRect::getPointOfSceneRightBottom().x - 15, 60*0.618 + STVisibleRect::getOriginalPoint().y));
        vedioBtn->setPosition(Vec2(STVisibleRect::getCenterOfScene().x, lightBtn->getBoundingBox().getMaxY() + 15));
        soundBtn->setPosition(settingBtn->getPosition()+Vec2(15, 0));
        shareBtn->setPosition(settingBtn->getPosition()+Vec2(15, 0));
        
        lightBtn->setCallback(CC_CALLBACK_1(HomeLayer::onClickedMenuItems, this));
        settingBtn->setCallback(CC_CALLBACK_1(HomeLayer::onClickedMenuItems, this));
        vedioBtn->setCallback(CC_CALLBACK_1(HomeLayer::onClickedMenuItems, this));
        
        
        Menu* pBtns = Menu::create(lightBtn, settingBtn, vedioBtn, NULL);
        pBtns->setAnchorPoint(Vec2(0, 0));
        pBtns->setPosition(Vec2(0, 0));
        addChild(pBtns, 2);
        
        float maxHeight = centerTitle->getBoundingBox().getMidY() - vedioBtn->getBoundingBox().getMaxY();
        log("the max height is %.2f", maxHeight);

        float tableHeight = maxHeight - 100*1.618;
        float tableWidth = STVisibleRect::getGlvisibleSize().width - 200*0.618;
        
        log("the tablewidth is %.2f, and the tableheight is %.2f", tableWidth, tableHeight);
        int w = (int)tableWidth;
        int h = (int)tableHeight;
        
        TableViewTest* pLayer = TableViewTest::create(Size(w, h));
        pLayer->setPosition(Vec2(100*0.618 + STVisibleRect::getOriginalPoint().x, vedioBtn->getBoundingBox().getMaxY() + 100*0.618));
        addChild(pLayer, 10);
        pLayer->setDelegate(this);
        return true;
    }
    return false;
}
开发者ID:850176300,项目名称:HuaRongBlock,代码行数:72,代码来源:HomeLayer.cpp


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