2013-09-16 20:54:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
#include "UIImageViewTest.h"
|
|
|
|
|
|
|
|
|
|
|
|
// UIImageViewTest
|
|
|
|
|
|
|
|
bool UIImageViewTest::init()
|
|
|
|
{
|
|
|
|
if (UIScene::init())
|
|
|
|
{
|
2013-12-23 15:35:35 +08:00
|
|
|
Size widgetSize = _widget->getSize();
|
2013-09-16 20:54:13 +08:00
|
|
|
|
2013-12-31 16:36:33 +08:00
|
|
|
gui::Text* alert = gui::Text::create();
|
2013-09-16 20:54:13 +08:00
|
|
|
alert->setText("ImageView");
|
2013-12-23 15:35:35 +08:00
|
|
|
alert->setFontName("Marker Felt");
|
2013-09-16 20:54:13 +08:00
|
|
|
alert->setFontSize(30);
|
|
|
|
alert->setColor(Color3B(159, 168, 176));
|
2013-12-23 15:35:35 +08:00
|
|
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
|
|
|
_uiLayer->addChild(alert);
|
2013-09-16 20:54:13 +08:00
|
|
|
|
|
|
|
// Create the imageview
|
2013-12-23 15:35:35 +08:00
|
|
|
ImageView* imageView = ImageView::create();
|
2013-09-16 20:54:13 +08:00
|
|
|
imageView->loadTexture("cocosgui/ccicon.png");
|
|
|
|
imageView->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
|
2013-12-23 15:35:35 +08:00
|
|
|
|
|
|
|
// 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->setZOrder(20);
|
2013-09-16 20:54:13 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UIImageViewTest_Scale9
|
|
|
|
|
|
|
|
bool UIImageViewTest_Scale9::init()
|
|
|
|
{
|
|
|
|
if (UIScene::init())
|
|
|
|
{
|
2013-12-23 15:35:35 +08:00
|
|
|
Size widgetSize = _widget->getSize();
|
2013-09-16 20:54:13 +08:00
|
|
|
|
2013-12-31 16:36:33 +08:00
|
|
|
gui::Text* alert = gui::Text::create();
|
2013-09-16 20:54:13 +08:00
|
|
|
alert->setText("ImageView scale9 render");
|
2013-12-23 15:35:35 +08:00
|
|
|
alert->setFontName("Marker Felt");
|
|
|
|
alert->setFontSize(26);
|
2013-09-16 20:54:13 +08:00
|
|
|
alert->setColor(Color3B(159, 168, 176));
|
2013-12-23 15:35:35 +08:00
|
|
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.125f));
|
|
|
|
_uiLayer->addChild(alert);
|
2013-09-16 20:54:13 +08:00
|
|
|
|
|
|
|
// Create the imageview
|
2013-12-23 15:35:35 +08:00
|
|
|
ImageView* imageView = ImageView::create();
|
2013-09-16 20:54:13 +08:00
|
|
|
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));
|
2013-12-23 15:35:35 +08:00
|
|
|
_uiLayer->addChild(imageView);
|
2013-09-16 20:54:13 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|