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
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
Text* alert = Text::create();
|
2013-09-16 20:54:13 +08:00
|
|
|
alert->setText("ImageView");
|
2014-03-26 23:33:58 +08:00
|
|
|
alert->setFontName("fonts/Marker Felt.ttf");
|
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();
|
2014-03-11 17:13:54 +08:00
|
|
|
imageView->loadTexture("cocosui/ccicon.png");
|
2013-09-16 20:54:13 +08:00
|
|
|
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();
|
2014-03-11 17:13:54 +08:00
|
|
|
static_cast<Sprite*>(render)->setTexture("cocosui/ccicon.png");
|
2013-12-23 15:35:35 +08:00
|
|
|
root->addChild(render);
|
|
|
|
// root->setOpacity(64);
|
|
|
|
root->setPosition(Point(200, 180));
|
|
|
|
_uiLayer->addChild(root);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
NodeRGBA* nodergba = NodeRGBA::create();
|
|
|
|
Sprite* child = Sprite::create();
|
2014-03-11 17:13:54 +08:00
|
|
|
child->setTexture("cocosui/ccicon.png");
|
2013-12-23 15:35:35 +08:00
|
|
|
nodergba->addChild(child);
|
|
|
|
nodergba->setPosition(Point(120, 80));
|
|
|
|
nodergba->setOpacity(64);
|
|
|
|
_uiLayer->addChild(nodergba);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Sprite* sprite = Sprite::create();
|
2014-03-11 17:13:54 +08:00
|
|
|
sprite->setTexture("cocosui/ccicon.png");
|
2013-12-23 15:35:35 +08:00
|
|
|
sprite->setPosition(Point(200, 180));
|
|
|
|
// sprite->setOpacity(64);
|
|
|
|
_uiLayer->addChild(sprite);
|
|
|
|
*/
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
// 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
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
Text* alert = Text::create();
|
2013-09-16 20:54:13 +08:00
|
|
|
alert->setText("ImageView scale9 render");
|
2014-03-26 23:33:58 +08:00
|
|
|
alert->setFontName("fonts/Marker Felt.ttf");
|
2013-12-23 15:35:35 +08:00
|
|
|
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);
|
2014-03-11 17:13:54 +08:00
|
|
|
imageView->loadTexture("cocosui/buttonHighlighted.png");
|
2013-09-16 20:54:13 +08:00
|
|
|
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;
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|