2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
#include "CustomImageTest.h"
|
2014-03-05 21:18:51 +08:00
|
|
|
#include "../../CustomGUIScene.h"
|
2014-03-04 16:51:35 +08:00
|
|
|
#include "../../CustomWidget/CustomImageView.h"
|
|
|
|
#include "../../CustomWidget/CustomImageViewReader.h"
|
|
|
|
#include "../../CustomWidget/CustomReader.h"
|
|
|
|
#include "cocostudio/CCSGUIReader.h"
|
|
|
|
|
2014-03-07 15:36:45 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
USING_NS_CC_EXT;
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-03-26 14:54:50 +08:00
|
|
|
|
|
|
|
// CustomImageLayer
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
void CustomImageLayer::onEnter()
|
|
|
|
{
|
|
|
|
Layer::onEnter();
|
|
|
|
|
|
|
|
GUIReader* guiReader = GUIReader::getInstance();
|
|
|
|
guiReader->registerTypeAndCallBack("CustomImageView",
|
|
|
|
&CustomImageView::createInstance,
|
|
|
|
CustomImageViewReader::getInstance(),
|
|
|
|
parseselector(CustomImageViewReader::setProperties));
|
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
Layout* layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/CustomImageViewTest/NewProject_2_1.ExportJson"));
|
2014-03-04 16:51:35 +08:00
|
|
|
addChild(layout);
|
|
|
|
}
|
|
|
|
|
2014-03-26 14:54:50 +08:00
|
|
|
|
|
|
|
// CustomImageScene
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
void CustomImageScene::onEnter()
|
|
|
|
{
|
|
|
|
CCScene::onEnter();
|
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label = Label::createWithTTF("Back", "fonts/arial.ttf", 20);
|
2014-03-04 16:51:35 +08:00
|
|
|
//#endif
|
|
|
|
MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(CustomImageScene::BackCallback, this));
|
|
|
|
|
2014-07-10 00:45:27 +08:00
|
|
|
Menu* pMenu = Menu::create(pMenuItem, nullptr);
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
pMenu->setPosition( Vec2::ZERO );
|
2014-08-28 11:41:18 +08:00
|
|
|
pMenuItem->setPosition(VisibleRect::right().x - 50, VisibleRect::bottom().y + 25);
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
addChild(pMenu, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomImageScene::runThisTest()
|
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
Layer* pLayer = new (std::nothrow) CustomImageLayer();
|
2014-03-04 16:51:35 +08:00
|
|
|
addChild(pLayer);
|
|
|
|
pLayer->release();
|
|
|
|
|
|
|
|
CCDirector::getInstance()->replaceScene(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomImageScene::BackCallback(Ref* pSender)
|
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
CustomGUITestScene* pScene = new (std::nothrow) CustomGUITestScene();
|
2014-03-04 16:51:35 +08:00
|
|
|
pScene->runThisTest();
|
|
|
|
pScene->release();
|
|
|
|
}
|