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


C++ ImageView::getSize方法代码示例

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


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

示例1: initWithDialog

bool LevelCompleteLoss::initWithDialog(Dialog* dialog)
{
	//if (!LayerColor::initWithColor(Color4B(255, 0, 0, 255))) return false;
	this->m_pDialog = dialog;

	Layout* layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("ui/Lose.json"));
	addChild(layout);

	ImageView *imageView = static_cast<ImageView*>(layout->getChildByName("Image_1"));
	this->setContentSize(imageView->getSize());

	Button * btn_menu = static_cast<Button*>(layout->getChildByName("btn_menu"));
	Button * btn_reset = static_cast<Button*>(layout->getChildByName("btn_reset"));
	Button * btn_next = static_cast<Button*>(layout->getChildByName("btn_next"));
	this->m_pLabelDesc = static_cast<Text*>(layout->getChildByName("label_desc"));

	btn_menu->addTouchEventListener(CC_CALLBACK_2(LevelCompleteLoss::btn_menuCallback,this));
	btn_reset->addTouchEventListener(CC_CALLBACK_2(LevelCompleteLoss::btn_resetCallback, this));

	layout->setAnchorPoint(Vec2(0.5,0.5));
	
	return true;
}
开发者ID:liujian890508,项目名称:boxgohome,代码行数:23,代码来源:LevelCompleteLoss.cpp

示例2: init

bool UIScrollViewTest_Horizontal::init()
{
    if (UIScene::init())
    {
        Size widgetSize = _widget->getSize();

        // Add a label in which the scrollview alert will be displayed
        _displayValueLabel = Text::create("Move by horizontal direction","fonts/Marker Felt.ttf",32);
        _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
        _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
        _uiLayer->addChild(_displayValueLabel);

        Text* alert = Text::create("ScrollView horizontal","fonts/Marker Felt.ttf",30);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
        _uiLayer->addChild(alert);

        Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));

        Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));

        // Create the scrollview by horizontal
        ui::ScrollView* scrollView = ui::ScrollView::create();
        scrollView->setBounceEnabled(true);
        scrollView->setDirection(ui::ScrollView::Direction::HORIZONTAL);
        scrollView->setSize(Size(280.0f, 150.0f));
        scrollView->setInnerContainerSize(scrollView->getSize());
        Size backgroundSize = background->getContentSize();
        scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
                                     (backgroundSize.width - scrollView->getSize().width) / 2.0f,
                                     (widgetSize.height - backgroundSize.height) / 2.0f +
                                     (backgroundSize.height - scrollView->getSize().height) / 2.0f));
        _uiLayer->addChild(scrollView);

        ImageView* imageView = ImageView::create("cocosui/ccicon.png");

        float innerWidth = scrollView->getSize().width + imageView->getSize().width;
        float innerHeight = scrollView->getSize().height;

        scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));

        Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
        button->setPosition(Vec2(button->getSize().width / 2.0f,
                                 scrollView->getInnerContainerSize().height - button->getSize().height / 2.0f));
        scrollView->addChild(button);

        Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
        titleButton->setTitleText("Title Button");
        titleButton->setPosition(Vec2(button->getRightInParent() + button->getSize().width / 2.0f,
                                      button->getBottomInParent() - button->getSize().height / 2.0f));
        scrollView->addChild(titleButton);

        Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
        button_scale9->setScale9Enabled(true);
        button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
        button_scale9->setPosition(Vec2(titleButton->getRightInParent() + titleButton->getSize().width / 2.0f,
                                        titleButton->getBottomInParent() - titleButton->getSize().height / 2.0f));
        scrollView->addChild(button_scale9);

        imageView->setPosition(Vec2(innerWidth - imageView->getSize().width / 2.0f,
                                    button_scale9->getBottomInParent() - button_scale9->getSize().height / 2.0f));
        scrollView->addChild(imageView);

        return true;
    }

    return false;
}
开发者ID:289997171,项目名称:cocos2d-x,代码行数:68,代码来源:UIScrollViewTest.cpp

示例3: init

bool UIImageViewTest::init()
{
    if (UIScene::init())
    {
        Size widgetSize = _widget->getSize();
        
        Text* alert = Text::create();
        alert->setText("ImageView");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
        _uiLayer->addChild(alert);        
        
        // Create the imageview
        ImageView* imageView = ImageView::create();
        imageView->loadTexture("cocosgui/ccicon.png");
        imageView->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
        
//        imageView->setOpacity(64);
        _uiLayer->addChild(imageView);
        
        /*
        NodeRGBA* root = NodeRGBA::create();
        root->setCascadeOpacityEnabled(true);
        NodeRGBA* render = Sprite::create();
        static_cast<Sprite*>(render)->setTexture("cocosgui/ccicon.png");
        root->addChild(render);
//        root->setOpacity(64);
        root->setPosition(Point(200, 180));
        _uiLayer->addChild(root);
         */
        
        /*
        NodeRGBA* nodergba = NodeRGBA::create();
        Sprite* child = Sprite::create();
        child->setTexture("cocosgui/ccicon.png");
        nodergba->addChild(child);
        nodergba->setPosition(Point(120, 80));
        nodergba->setOpacity(64);
        _uiLayer->addChild(nodergba);
         */
        
        /*
        Sprite* sprite = Sprite::create();
        sprite->setTexture("cocosgui/ccicon.png");
        sprite->setPosition(Point(200, 180));
//        sprite->setOpacity(64);
        _uiLayer->addChild(sprite);
         */
        
//        imageView->setLocalZOrder(20);
        
        return true;
    }
    return false;
}
开发者ID:6520874,项目名称:CocoStudioSamplesBasedOnCocos2d-x3.0,代码行数:57,代码来源:UIImageViewTest.cpp

示例4:

bool UIImageViewTest_Scale9::init()
{
    if (UIScene::init())
    {
        Size widgetSize = _widget->getSize();
        
        Text* alert = Text::create();
        alert->setText("ImageView scale9 render");
        alert->setFontName("Marker Felt");
        alert->setFontSize(26);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.125f));
        _uiLayer->addChild(alert);        
        
        // Create the imageview
        ImageView* imageView = ImageView::create();
        imageView->setScale9Enabled(true);
        imageView->loadTexture("cocosgui/buttonHighlighted.png");
        imageView->setSize(Size(200, 85));
        imageView->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
        _uiLayer->addChild(imageView);                
        
        return true;
    }
    return false;
}
开发者ID:6520874,项目名称:CocoStudioSamplesBasedOnCocos2d-x3.0,代码行数:26,代码来源:UIImageViewTest.cpp

示例5: init

bool pauseUI::init()
{
    auto s = Director::getInstance()->getWinSize();
    auto layer = LayerColor::create(Color4B(100,100,100,90));
    addChild(layer);
    
    // Create the imageview
    ImageView* back = ImageView::create();
    back->setScale9Enabled(true);
    back->loadTexture("UI/green_edit.png");
    back->setSize(Size(s.width*0.8, s.height*0.4));
    back->setPosition(Point(s.width/2,s.height/2));
    this->addChild(back);
    
    
    const char* normal = "UI/normal.png";
    const char* pressed = "UI/press.png";
    
    // Add the alert
    gui::Text* alert = gui::Text::create();
    alert->setText("继续游戏");
    alert->setFontName("Marker Felt");
    alert->setFontSize(30);

    // Create the button //继续游戏
    Button* button = Button::create();
    button->setTouchEnabled(true);
    // open scale9 render
    button->setScale9Enabled(true);
    button->loadTextures(normal, pressed, "");
    button->setSize(Size(button->getContentSize().width*3, button->getContentSize().height));
    button->addChild(alert);
    button->addTouchEventListener(this, toucheventselector(pauseUI::continueButtonEvent));
    back->addChild(button);
    button->setPosition(Point(0, back->getSize().height/2 - button->getSize().height));

    
    Point lastPt = button->getPosition();
    
    int step = (back->getSize().height - button->getSize().height*3)/4;
    
    
    // Add the alert
    alert = gui::Text::create();
    alert->setText("重新开始");
    alert->setFontName("Marker Felt");
    alert->setFontSize(30);
    
    // Create the button //继续游戏
    button = Button::create();
    button->setTouchEnabled(true);
    // open scale9 render
    button->setScale9Enabled(true);
    button->loadTextures(normal, pressed, "");
    button->setSize(Size(button->getContentSize().width*3, button->getContentSize().height));
    button->setPosition(Point(0, lastPt.y - button->getContentSize().height-step));
    button->addChild(alert);
    button->addTouchEventListener(this, toucheventselector(pauseUI::restartButtonEvent));
    back->addChild(button);
    
    
    lastPt = button->getPosition();
    
    // Add the alert
    alert = gui::Text::create();
    alert->setText("回主界面");
    alert->setFontName("Marker Felt");
    alert->setFontSize(30);
    
    // Create the button //继续游戏
    button = Button::create();
    button->setTouchEnabled(true);
    // open scale9 render
    button->setScale9Enabled(true);
    button->loadTextures(normal, pressed, "");
    button->setSize(Size(button->getContentSize().width*3, button->getContentSize().height));
    button->setPosition(Point(0, lastPt.y - button->getContentSize().height-step));
    button->addChild(alert);
    button->addTouchEventListener(this, toucheventselector(pauseUI::backMainUIButtonEvent));
    back->addChild(button);
    
    auto scale = ScaleTo::create(1.0f, 1.0f);
    back->setScale(0.0f);
    back->runAction(EaseElasticOut::create(scale, 1.0f));
    return true;
}
开发者ID:rickystone,项目名称:Match2,代码行数:86,代码来源:pauseUI.cpp


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