本文整理汇总了C++中ImageView::isScale9Enabled方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageView::isScale9Enabled方法的具体用法?C++ ImageView::isScale9Enabled怎么用?C++ ImageView::isScale9Enabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageView
的用法示例。
在下文中一共展示了ImageView::isScale9Enabled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPropsFromBinary
void ImageViewReader::setPropsFromBinary(cocos2d::ui::Widget *widget, CocoLoader *cocoLoader, stExpCocoNode *cocoNode)
{
WidgetReader::setPropsFromBinary(widget, cocoLoader, cocoNode);
ImageView* imageView = static_cast<ImageView*>(widget);
this->beginSetBasicProperties(widget);
float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f;
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue(cocoLoader);
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
//read all color related properties of widget
CC_COLOR_PROPERTY_BINARY_READER
else if (key == P_Scale9Enable) {
imageView->setScale9Enabled(valueToBool(value));
}
else if (key == P_FileNameData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
imageView->loadTexture(backgroundValue, imageFileNameType);
}
else if(key == P_Scale9Width){
imageView->setContentSize(Size(valueToFloat(value), imageView->getContentSize().height));
}else if(key == P_Scale9Height){
imageView->setContentSize(Size(imageView->getContentSize().width, valueToFloat(value)));
}
else if(key == P_CapInsetsX){
capsx = valueToFloat(value);
}else if(key == P_CapInsetsY){
capsy = valueToFloat(value);
}else if(key == P_CapInsetsWidth){
capsWidth = valueToFloat(value);
}else if(key == P_CapInsetsHeight){
capsHeight = valueToFloat(value);
}
} //end of for loop
if (imageView->isScale9Enabled()) {
imageView->setCapInsets(Rect(capsx, capsy, capsWidth, capsHeight));
}
this->endSetBasicProperties(widget);
}
示例2: init
bool UIImageViewFlipTest::init()
{
if (UIScene::init())
{
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/blocks9ss.plist");
Size widgetSize = _widget->getContentSize();
Text* alert = Text::create("ImageView flip test", "fonts/Marker Felt.ttf", 26);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f - alert->getContentSize().height * 2.125f));
_uiLayer->addChild(alert);
// Create the imageview
ImageView* imageView = ImageView::create("blocks9r.png", Widget::TextureResType::PLIST);
imageView->setScale9Enabled(true);
imageView->setContentSize(Size(250, 115));
imageView->setFlippedX(true);
imageView->setScale(0.5);
imageView->ignoreContentAdaptWithSize(false);
imageView->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f));
_uiLayer->addChild(imageView);
auto toggleButton = Button::create();
toggleButton->setTitleText("Toggle FlipX");
toggleButton->setPosition(imageView->getPosition() + Vec2(-50, - imageView->getContentSize().height/2 - 20));
this->addChild(toggleButton);
toggleButton->addClickEventListener([=](Ref*){
imageView->setFlippedX(!imageView->isFlippedX());
});
auto toggleScale9 = Button::create();
toggleScale9->setTitleText("Toggle Scale9");
toggleScale9->setPosition(imageView->getPosition() + Vec2(+50, - imageView->getContentSize().height/2- 20));
this->addChild(toggleScale9);
toggleScale9->addClickEventListener([=](Ref*){
imageView->setScale9Enabled(!imageView->isScale9Enabled());
//after switching scale9, you must call setContentSize to keep the size not change
imageView->setContentSize(Size(250, 115));
});
return true;
}
return false;
}
示例3:
bool UIImageViewTest_Scale9_State_Change::init()
{
if (UIScene::init())
{
Size widgetSize = _widget->getContentSize();
Text* alert = Text::create("Click The Image", "fonts/Marker Felt.ttf", 26);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f - alert->getContentSize().height * 2.125f));
_uiLayer->addChild(alert);
// Create the imageview
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
imageView->ignoreContentAdaptWithSize(false);
imageView->setScale9Enabled(true);
imageView->setContentSize(Size(100, 100));
imageView->setCapInsets(Rect(20,20,20,20));
imageView->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f));
imageView->setTouchEnabled(true);
imageView->addTouchEventListener([=](Ref* sender, Widget::TouchEventType type){
if (type == Widget::TouchEventType::ENDED) {
if (imageView->isScale9Enabled())
{
imageView->setScale9Enabled(false);
}
else
imageView->setScale9Enabled(true);
}
});
_uiLayer->addChild(imageView);
return true;
}
return false;
}