2013-09-16 20:54:13 +08:00
|
|
|
#include "CocosGUIScene.h"
|
2014-03-04 16:51:35 +08:00
|
|
|
#include "CocoStudioGUITest.h"
|
2013-09-16 20:54:13 +08:00
|
|
|
#include "UISceneManager.h"
|
2013-10-16 11:19:01 +08:00
|
|
|
#include "cocostudio/CocoStudio.h"
|
2013-09-16 20:54:13 +08:00
|
|
|
|
2013-12-23 15:35:35 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
LINE_SPACE = 40,
|
|
|
|
kItemTagBasic = 1000,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
const char *name;
|
2014-02-20 10:53:49 +08:00
|
|
|
std::function<void(Ref* sender)> callback;
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
g_guisTests[] =
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
|
|
|
{
|
|
|
|
"VideoPlayerTest",
|
|
|
|
[](Ref* sender)
|
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUIVideoPlayerTest);
|
|
|
|
sceneManager->setMinUISceneId(kUIVideoPlayerTest);
|
|
|
|
sceneManager->setMaxUISceneId(kUIVideoPlayerTest);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2014-05-14 11:26:04 +08:00
|
|
|
}
|
|
|
|
},
|
2014-08-26 11:39:56 +08:00
|
|
|
#endif
|
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
|
|
|
{
|
|
|
|
"WebViewTest",
|
|
|
|
[](Ref* sender)
|
|
|
|
{
|
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(KWebViewTest);
|
|
|
|
sceneManager->setMinUISceneId(KWebViewTest);
|
|
|
|
sceneManager->setMaxUISceneId(KWebViewTest);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
|
|
|
}
|
|
|
|
},
|
2014-05-14 11:26:04 +08:00
|
|
|
#endif
|
2014-09-19 14:21:18 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
2014-09-01 15:55:09 +08:00
|
|
|
{
|
|
|
|
"EditBox Test",
|
|
|
|
[](Ref* sender)
|
|
|
|
{
|
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUIEditBoxTest);
|
|
|
|
sceneManager->setMinUISceneId(kUIEditBoxTest);
|
|
|
|
sceneManager->setMaxUISceneId(kUIEditBoxTest);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
|
|
|
}
|
|
|
|
},
|
2014-09-19 14:21:18 +08:00
|
|
|
#endif
|
2014-05-08 11:26:29 +08:00
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"focus test",
|
2014-05-08 11:26:29 +08:00
|
|
|
[](Ref* sender)
|
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(KUIFocusTest_HBox);
|
|
|
|
sceneManager->setMinUISceneId(KUIFocusTest_HBox);
|
2014-08-30 03:54:24 +08:00
|
|
|
// TODO: improve ListView focus
|
2014-06-25 14:04:32 +08:00
|
|
|
sceneManager->setMaxUISceneId(KUIFocusTest_NestedLayout3);
|
2014-05-14 17:07:24 +08:00
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2014-05-08 11:26:29 +08:00
|
|
|
}
|
2014-07-29 14:33:22 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"Scale9 Sprite Test",
|
|
|
|
[](Ref* sender)
|
|
|
|
{
|
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUIScale9SpriteTest);
|
|
|
|
sceneManager->setMinUISceneId(kUIScale9SpriteTest);
|
2014-08-05 08:11:37 +08:00
|
|
|
sceneManager->setMaxUISceneId(kUIS9ChangeAnchorPoint);
|
2014-07-29 14:33:22 +08:00
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
|
|
|
}
|
2014-05-08 11:26:29 +08:00
|
|
|
},
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-08 11:26:29 +08:00
|
|
|
|
2014-05-14 11:26:04 +08:00
|
|
|
"ButtonTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUIButtonTest);
|
|
|
|
sceneManager->setMinUISceneId(kUIButtonTest);
|
2014-09-17 10:57:40 +08:00
|
|
|
sceneManager->setMaxUISceneId(kUIButtonTitleEffectTest);
|
2014-05-14 17:07:24 +08:00
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"CheckBoxTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUICheckBoxTest);
|
|
|
|
sceneManager->setMinUISceneId(kUICheckBoxTest);
|
|
|
|
sceneManager->setMaxUISceneId(kUICheckBoxTest);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"SliderTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUISliderTest);
|
|
|
|
sceneManager->setMinUISceneId(kUISliderTest);
|
|
|
|
sceneManager->setMaxUISceneId(kUISliderTest_Scale9);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"ImageViewTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUIImageViewTest);
|
|
|
|
sceneManager->setMinUISceneId(kUIImageViewTest);
|
2014-07-24 11:52:42 +08:00
|
|
|
sceneManager->setMaxUISceneId(kUIImageViewTest_ContentSize);
|
2014-05-14 17:07:24 +08:00
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"LoadingBarTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUILoadingBarTest_Left);
|
|
|
|
sceneManager->setMinUISceneId(kUILoadingBarTest_Left);
|
|
|
|
sceneManager->setMaxUISceneId(kUILoadingBarTest_Right_Scale9);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"TextAtalsTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUITextAtlasTest);
|
|
|
|
sceneManager->setMinUISceneId(kUITextAtlasTest);
|
|
|
|
sceneManager->setMaxUISceneId(kUITextAtlasTest);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"TextTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUITextTest);
|
|
|
|
sceneManager->setMinUISceneId(kUITextTest);
|
|
|
|
sceneManager->setMaxUISceneId(kUITextTest_TTF);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"TextBMFontTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUITextBMFontTest);
|
|
|
|
sceneManager->setMinUISceneId(kUITextBMFontTest);
|
|
|
|
sceneManager->setMaxUISceneId(kUITextBMFontTest);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"TextFieldTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUITextFieldTest);
|
|
|
|
sceneManager->setMinUISceneId(kUITextFieldTest);
|
2014-08-13 11:28:37 +08:00
|
|
|
sceneManager->setMaxUISceneId(kUITextFieldTest_PlaceHolderColor);
|
2014-05-14 17:07:24 +08:00
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"LayoutTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUILayoutTest);
|
|
|
|
sceneManager->setMinUISceneId(kUILayoutTest);
|
|
|
|
sceneManager->setMaxUISceneId(kUILayoutTest_Layout_Relative_Location);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"ScrollViewTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUIScrollViewTest_Vertical);
|
|
|
|
sceneManager->setMinUISceneId(kUIScrollViewTest_Vertical);
|
2014-08-15 16:21:27 +08:00
|
|
|
sceneManager->setMaxUISceneId(kUIScrollViewNestTest);
|
2014-05-14 17:07:24 +08:00
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"PageViewTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUIPageViewTest);
|
|
|
|
sceneManager->setMinUISceneId(kUIPageViewTest);
|
2014-08-15 15:28:28 +08:00
|
|
|
sceneManager->setMaxUISceneId(kUIPageViewTouchPropagationTest);
|
2014-05-14 17:07:24 +08:00
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"ListViewTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUIListViewTest_Vertical);
|
|
|
|
sceneManager->setMinUISceneId(kUIListViewTest_Vertical);
|
|
|
|
sceneManager->setMaxUISceneId(kUIListViewTest_Horizontal);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"WidgetAddNodeTest",
|
2014-02-20 10:53:49 +08:00
|
|
|
[](Ref* sender)
|
2013-12-23 15:35:35 +08:00
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUIWidgetAddNodeTest);
|
|
|
|
sceneManager->setMinUISceneId(kUIWidgetAddNodeTest);
|
|
|
|
sceneManager->setMaxUISceneId(kUIWidgetAddNodeTest);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2014-03-06 20:52:29 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-05-14 11:26:04 +08:00
|
|
|
"RichTextTest",
|
2014-03-06 20:52:29 +08:00
|
|
|
[](Ref* sender)
|
|
|
|
{
|
2014-05-14 17:07:24 +08:00
|
|
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
|
|
|
sceneManager->setCurrentUISceneId(kUIRichTextTest);
|
|
|
|
sceneManager->setMinUISceneId(kUIRichTextTest);
|
|
|
|
sceneManager->setMaxUISceneId(kUIRichTextTest);
|
|
|
|
Scene* scene = sceneManager->currentUIScene();
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
2013-12-23 15:35:35 +08:00
|
|
|
}
|
|
|
|
},
|
2014-05-14 11:26:04 +08:00
|
|
|
|
2013-12-23 15:35:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const int g_maxTests = sizeof(g_guisTests) / sizeof(g_guisTests[0]);
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
static Vec2 s_tCurPos = Vec2::ZERO;
|
2013-12-23 15:35:35 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// CocosGUITestMainLayer
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
void CocosGUITestMainLayer::onEnter()
|
|
|
|
{
|
|
|
|
Layer::onEnter();
|
|
|
|
|
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
|
|
|
|
_itemMenu = Menu::create();
|
|
|
|
_itemMenu->setPosition( s_tCurPos );
|
2014-03-26 23:33:58 +08:00
|
|
|
MenuItemFont::setFontName("fonts/arial.ttf");
|
2013-12-23 15:35:35 +08:00
|
|
|
MenuItemFont::setFontSize(24);
|
|
|
|
for (int i = 0; i < g_maxTests; ++i)
|
|
|
|
{
|
|
|
|
auto pItem = MenuItemFont::create(g_guisTests[i].name, g_guisTests[i].callback);
|
2014-08-28 11:41:18 +08:00
|
|
|
pItem->setPosition(s.width / 2, s.height - (i + 1) * LINE_SPACE);
|
2013-12-23 15:35:35 +08:00
|
|
|
_itemMenu->addChild(pItem, kItemTagBasic + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto listener = EventListenerTouchAllAtOnce::create();
|
|
|
|
listener->onTouchesBegan = CC_CALLBACK_2(CocosGUITestMainLayer::onTouchesBegan, this);
|
|
|
|
listener->onTouchesMoved = CC_CALLBACK_2(CocosGUITestMainLayer::onTouchesMoved, this);
|
|
|
|
|
|
|
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
|
|
|
|
|
|
|
addChild(_itemMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CocosGUITestMainLayer::onTouchesBegan(const std::vector<Touch*>& touches, Event *event)
|
|
|
|
{
|
|
|
|
auto touch = static_cast<Touch*>(touches[0]);
|
|
|
|
|
|
|
|
_beginPos = touch->getLocation();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CocosGUITestMainLayer::onTouchesMoved(const std::vector<Touch*>& touches, Event *event)
|
|
|
|
{
|
|
|
|
auto touch = static_cast<Touch*>(touches[0]);
|
|
|
|
|
|
|
|
auto touchLocation = touch->getLocation();
|
|
|
|
float nMoveY = touchLocation.y - _beginPos.y;
|
|
|
|
|
|
|
|
auto curPos = _itemMenu->getPosition();
|
2014-05-15 01:07:09 +08:00
|
|
|
auto nextPos = Vec2(curPos.x, curPos.y + nMoveY);
|
2013-12-23 15:35:35 +08:00
|
|
|
|
|
|
|
if (nextPos.y < 0.0f)
|
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
_itemMenu->setPosition(Vec2::ZERO);
|
2013-12-23 15:35:35 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nextPos.y > ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))
|
|
|
|
{
|
2014-08-28 11:41:18 +08:00
|
|
|
_itemMenu->setPosition(0, ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height));
|
2013-12-23 15:35:35 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_itemMenu->setPosition(nextPos);
|
|
|
|
_beginPos = touchLocation;
|
|
|
|
s_tCurPos = nextPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// CocosGUITestScene
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
void CocosGUITestScene::onEnter()
|
|
|
|
{
|
|
|
|
Scene::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
|
|
|
|
auto pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(CocosGUITestScene::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);
|
|
|
|
}
|
|
|
|
|
2013-12-23 15:35:35 +08:00
|
|
|
void CocosGUITestScene::runThisTest()
|
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
auto layer = new (std::nothrow) CocosGUITestMainLayer();
|
2013-12-23 15:35:35 +08:00
|
|
|
addChild(layer);
|
|
|
|
layer->release();
|
|
|
|
|
|
|
|
Director::getInstance()->replaceScene(this);
|
2014-03-04 16:51:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CocosGUITestScene::BackCallback(Ref* pSender)
|
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
CocoStudioGUITestScene* pScene = new (std::nothrow) CocoStudioGUITestScene();
|
2014-03-04 16:51:35 +08:00
|
|
|
pScene->runThisTest();
|
|
|
|
pScene->release();
|
|
|
|
}
|