axmol/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp

883 lines
21 KiB
C++
Raw Normal View History

2013-09-20 22:23:13 +08:00
#include "extensions/cocos-ext.h"
2013-09-20 22:23:13 +08:00
#include "../ExtensionsTest.h"
#include "SceneEditorTest.h"
#include "cocostudio/CocoStudio.h"
2014-03-11 17:13:54 +08:00
#include "ui/CocosGUI.h"
2013-12-26 01:17:04 +08:00
#include "TriggerCode/EventDef.h"
#include "../../testResource.h"
2013-09-20 22:23:13 +08:00
using namespace cocos2d;
using namespace cocostudio;
using namespace ui;
2013-09-20 22:23:13 +08:00
Layer *Next();
Layer *Back();
Layer *Restart();
static int s_nIdx = -1;
Layer *createTests(int index)
2013-09-20 22:23:13 +08:00
{
Layer *layer = nullptr;
switch(index)
{
case TEST_LOADSCENEEDITORFILE:
layer = new LoadSceneEdtiorFileTest();
break;
case TEST_SPIRTECOMPONENT:
layer = new SpriteComponentTest();
break;
case TEST_ARMATURECOMPONENT:
layer = new ArmatureComponentTest();
break;
case TEST_UICOMPONENT:
layer = new UIComponentTest();
break;
case TEST_TMXMAPCOMPONENT:
layer = new TmxMapComponentTest();
break;
case TEST_PARTICLECOMPONENT:
layer = new ParticleComponentTest();
break;
case TEST_EFEECTCOMPONENT:
layer = new EffectComponentTest();
break;
case TEST_BACKGROUNDCOMPONENT:
layer = new BackgroundComponentTest();
break;
case TEST_ATTRIBUTECOMPONENT:
layer = new AttributeComponentTest();
break;
case TEST_TRIGGER:
layer = new TriggerTest();
break;
default:
break;
}
return layer;
}
Layer *Next()
{
++s_nIdx;
s_nIdx = s_nIdx % TEST_SCENEEDITOR_COUNT;
Layer *layer = createTests(s_nIdx);
layer->autorelease();
return layer;
}
Layer *Back()
{
--s_nIdx;
if( s_nIdx < 0 )
s_nIdx += TEST_SCENEEDITOR_COUNT;
Layer *layer = createTests(s_nIdx);
layer->autorelease();
return layer;
}
Layer *Restart()
{
Layer *layer = createTests(s_nIdx);
layer->autorelease();
return layer;
}
SceneEditorTestScene::SceneEditorTestScene(bool bPortrait)
{
TestScene::init();
}
void SceneEditorTestScene::runThisTest()
{
s_nIdx = -1;
addChild(Next());
CCDirector::getInstance()->replaceScene(this);
}
void SceneEditorTestScene::MainMenuCallback(Ref *pSender)
{
removeAllChildren();
}
const char* SceneEditorTestLayer::_loadtypeStr[2] = {"change to load \nwith binary file","change to load \nwith json file"};
void SceneEditorTestLayer::onEnter()
{
CCLayer::onEnter();
// add title and subtitle
std::string str = title();
const char *pTitle = str.c_str();
auto label = Label::createWithTTF(pTitle, "fonts/arial.ttf", 18);
label->setTextColor(Color4B::WHITE);
addChild(label, 1, 10000);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
label->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 30) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
auto l = Label::createWithTTF(strSubtitle.c_str(), "fonts/arial.ttf", 18);
l->setTextColor(Color4B::BLACK);
addChild(l, 1, 10001);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
l->setPosition(Vec2(VisibleRect::center().x, VisibleRect::top().y - 60) );
}
_isCsbLoad = false;
_loadtypelb = cocos2d::Label::createWithSystemFont(_loadtypeStr[0], "Arial", 12);
2014-06-25 14:32:38 +08:00
// #endif
MenuItemLabel* itemlb = CCMenuItemLabel::create(_loadtypelb, CC_CALLBACK_1(SceneEditorTestLayer::changeLoadTypeCallback, this));
Menu* loadtypemenu = CCMenu::create(itemlb, nullptr);
2014-06-25 14:32:38 +08:00
loadtypemenu->setPosition(Point(VisibleRect::rightTop().x -50,VisibleRect::rightTop().y -20));
addChild(loadtypemenu,100);
// add menu
backItem = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(SceneEditorTestLayer::backCallback, this) );
restartItem = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(SceneEditorTestLayer::restartCallback, this) );
nextItem = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(SceneEditorTestLayer::nextCallback, this) );
Menu *menu = Menu::create(backItem, restartItem, nextItem, nullptr);
float fScale = 0.5f;
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
menu->setPosition(Vec2(0, 0));
backItem->setPosition(Vec2(VisibleRect::center().x - restartItem->getContentSize().width * 2 * fScale, VisibleRect::bottom().y + restartItem->getContentSize().height / 2));
backItem->setScale(fScale);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
restartItem->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y + restartItem->getContentSize().height / 2));
restartItem->setScale(fScale);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
nextItem->setPosition(Vec2(VisibleRect::center().x + restartItem->getContentSize().width * 2 * fScale, VisibleRect::bottom().y + restartItem->getContentSize().height / 2));
nextItem->setScale(fScale);
addChild(menu, 100);
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
}
void SceneEditorTestLayer::onExit()
{
removeAllChildren();
backItem = restartItem = nextItem = nullptr;
Layer::onExit();
}
std::string SceneEditorTestLayer::title()
{
return "SceneReader Test LoadSceneEditorFile";
}
std::string SceneEditorTestLayer::subtitle()
{
return "";
}
void SceneEditorTestLayer::restartCallback(Ref *pSender)
{
Scene *s = new SceneEditorTestScene();
s->addChild(Restart());
Director::getInstance()->replaceScene(s);
s->release();
}
void SceneEditorTestLayer::nextCallback(Ref *pSender)
{
Scene *s = new SceneEditorTestScene();
s->addChild(Next());
Director::getInstance()->replaceScene(s);
s->release();
}
void SceneEditorTestLayer::backCallback(Ref *pSender)
{
Scene *s = new SceneEditorTestScene();
s->addChild(Back());
Director::getInstance()->replaceScene(s);
s->release();
}
void SceneEditorTestLayer::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
Layer::draw(renderer, transform, flags);
}
2014-06-25 14:32:38 +08:00
void SceneEditorTestLayer::changeLoadTypeCallback(cocos2d::Ref *pSender)
{
_isCsbLoad = !_isCsbLoad;
_loadtypelb->setString(_loadtypeStr[(int)_isCsbLoad]);
loadFileChangeHelper(_filePath);
2014-06-25 14:32:38 +08:00
if(_rootNode != nullptr)
2014-06-25 14:32:38 +08:00
{
this->removeChild(_rootNode);
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
2014-06-25 14:32:38 +08:00
{
return ;
}
defaultPlay();
this->addChild(_rootNode);
2014-06-25 14:32:38 +08:00
}
}
void SceneEditorTestLayer::loadFileChangeHelper(std::string& filePathName)
{
std::string::size_type n = filePathName.find_last_of(".");
if(n == std::string::npos)
return;
filePathName = filePathName.substr(0,n);
if(_isCsbLoad)
2014-06-25 14:32:38 +08:00
filePathName.append(".csb");
else
filePathName.append(".json");
}
LoadSceneEdtiorFileTest::LoadSceneEdtiorFileTest()
{
}
LoadSceneEdtiorFileTest::~LoadSceneEdtiorFileTest()
{
}
std::string LoadSceneEdtiorFileTest::title()
{
return "loadSceneEdtiorFile Test";
}
void LoadSceneEdtiorFileTest::onEnter()
{
SceneEditorTestLayer::onEnter();
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
this->addChild(root, 0, 1);
} while (0);
}
void LoadSceneEdtiorFileTest::onExit()
{
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
SceneEditorTestLayer::onExit();
}
cocos2d::Node* LoadSceneEdtiorFileTest::createGameScene()
{
_filePath = "scenetest/LoadSceneEdtiorFileTest/FishJoy2.json"; //default is json
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
2014-06-25 14:32:38 +08:00
defaultPlay();
return _rootNode;
2014-06-25 14:32:38 +08:00
}
void LoadSceneEdtiorFileTest::defaultPlay()
{
}
SpriteComponentTest::SpriteComponentTest()
{
}
SpriteComponentTest::~SpriteComponentTest()
{
2013-09-20 22:23:13 +08:00
}
std::string SpriteComponentTest::title()
2013-09-20 22:23:13 +08:00
{
return "Sprite Component Test";
2013-09-20 22:23:13 +08:00
}
void SpriteComponentTest::onEnter()
2013-09-20 22:23:13 +08:00
{
SceneEditorTestLayer::onEnter();
2013-09-20 22:23:13 +08:00
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
this->addChild(root, 0, 1);
} while (0);
}
2013-09-20 22:23:13 +08:00
void SpriteComponentTest::onExit()
{
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
SceneEditorTestLayer::onExit();
}
2013-09-20 22:23:13 +08:00
cocos2d::Node* SpriteComponentTest::createGameScene()
{
_filePath = "scenetest/SpriteComponentTest/SpriteComponentTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
2014-06-25 14:32:38 +08:00
defaultPlay();
return _rootNode;
2014-06-25 14:32:38 +08:00
}
void SpriteComponentTest::defaultPlay()
{
ActionInterval* action1 = CCBlink::create(2, 10);
ActionInterval* action2 = CCBlink::create(2, 5);
ComRender *pSister1 = static_cast<ComRender*>(_rootNode->getChildByTag(10003)->getComponent("CCSprite"));
pSister1->getNode()->runAction(action1);
ComRender *pSister2 = static_cast<ComRender*>(_rootNode->getChildByTag(10004)->getComponent("CCSprite"));
pSister2->getNode()->runAction(action2);
}
ArmatureComponentTest::ArmatureComponentTest()
{
}
ArmatureComponentTest::~ArmatureComponentTest()
{
}
std::string ArmatureComponentTest::title()
{
return "Armature Component Test";
}
void ArmatureComponentTest::onEnter()
{
SceneEditorTestLayer::onEnter();
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
this->addChild(root, 0, 1);
2013-09-20 22:23:13 +08:00
} while (0);
}
2013-09-20 22:23:13 +08:00
void ArmatureComponentTest::onExit()
{
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
SceneEditorTestLayer::onExit();
2013-09-20 22:23:13 +08:00
}
cocos2d::Node* ArmatureComponentTest::createGameScene()
{
_filePath = "scenetest/ArmatureComponentTest/ArmatureComponentTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
2014-06-25 14:32:38 +08:00
defaultPlay();
return _rootNode;
2014-06-25 14:32:38 +08:00
}
2014-06-25 14:32:38 +08:00
void ArmatureComponentTest::defaultPlay()
{
ComRender *pBlowFish = static_cast<ComRender*>(_rootNode->getChildByTag(10007)->getComponent("CCArmature"));
2014-06-25 14:32:38 +08:00
pBlowFish->getNode()->runAction(MoveBy::create(10.0f, Point(-1000.0f, 0)));
ComRender *pButterflyfish = static_cast<ComRender*>(_rootNode->getChildByTag(10008)->getComponent("CCArmature"));
2014-06-25 14:32:38 +08:00
pButterflyfish->getNode()->runAction(MoveBy::create(10.0f, Point(-1000.0f, 0)));
}
UIComponentTest::UIComponentTest()
{
}
UIComponentTest::~UIComponentTest()
{
}
std::string UIComponentTest::title()
{
return "UI Component Test";
}
void UIComponentTest::onEnter()
{
SceneEditorTestLayer::onEnter();
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
this->addChild(root, 0, 1);
} while (0);
}
void UIComponentTest::onExit()
{
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
SceneEditorTestLayer::onExit();
}
cocos2d::Node* UIComponentTest::createGameScene()
{
_filePath = "scenetest/UIComponentTest/UIComponentTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
2014-06-25 14:32:38 +08:00
defaultPlay();
return _rootNode;
}
void UIComponentTest::touchEvent(Ref *pSender, ui::Widget::TouchEventType type)
{
switch (type)
{
case ui::Widget::TouchEventType::BEGAN:
{
ComRender *pBlowFish = static_cast<ComRender*>(_rootNode->getChildByTag(10010)->getComponent("CCArmature"));
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0)));
ComRender *pButterflyfish = static_cast<ComRender*>(_rootNode->getChildByTag(10011)->getComponent("CCArmature"));
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0)));
}
break;
default:
break;
}
}
2014-06-25 14:32:38 +08:00
void UIComponentTest::defaultPlay()
{
ComRender *render = static_cast<ComRender*>(_rootNode->getChildByTag(10025)->getComponent("GUIComponent"));
2014-06-25 14:32:38 +08:00
Widget* widget = static_cast<cocos2d::ui::Widget*>(render->getNode());
Button* button = static_cast<Button*>(widget->getChildByName("Button_156"));
button->addTouchEventListener(CC_CALLBACK_2(UIComponentTest::touchEvent, this));
}
TmxMapComponentTest::TmxMapComponentTest()
{
}
TmxMapComponentTest::~TmxMapComponentTest()
{
}
std::string TmxMapComponentTest::title()
{
return "TmxMap Component Test";
}
void TmxMapComponentTest::onEnter()
{
SceneEditorTestLayer::onEnter();
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
this->addChild(root, 0, 1);
} while (0);
}
void TmxMapComponentTest::onExit()
{
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
SceneEditorTestLayer::onExit();
}
cocos2d::Node* TmxMapComponentTest::createGameScene()
{
_filePath = "scenetest/TmxMapComponentTest/TmxMapComponentTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
2014-06-25 14:32:38 +08:00
defaultPlay();
return _rootNode;
2014-06-25 14:32:38 +08:00
}
void TmxMapComponentTest::defaultPlay()
{
ComRender *tmxMap = static_cast<ComRender*>(_rootNode->getChildByTag(10015)->getComponent("CCTMXTiledMap"));
2014-06-25 14:32:38 +08:00
ActionInterval *actionTo = CCSkewTo::create(2, 0.f, 2.f);
ActionInterval *rotateTo = CCRotateTo::create(2, 61.0f);
ActionInterval *actionScaleTo = CCScaleTo::create(2, -0.44f, 0.47f);
2014-06-25 14:32:38 +08:00
ActionInterval *actionScaleToBack = CCScaleTo::create(2, 1.0f, 1.0f);
ActionInterval *rotateToBack = CCRotateTo::create(2, 0);
ActionInterval *actionToBack = CCSkewTo::create(2, 0, 0);
tmxMap->getNode()->runAction(CCSequence::create(actionTo, actionToBack, nullptr));
tmxMap->getNode()->runAction(CCSequence::create(rotateTo, rotateToBack, nullptr));
tmxMap->getNode()->runAction(CCSequence::create(actionScaleTo, actionScaleToBack, nullptr));
}
ParticleComponentTest::ParticleComponentTest()
{
}
ParticleComponentTest::~ParticleComponentTest()
{
}
std::string ParticleComponentTest::title()
{
return "Particle Component Test";
}
void ParticleComponentTest::onEnter()
{
SceneEditorTestLayer::onEnter();
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
this->addChild(root, 0, 1);
} while (0);
}
void ParticleComponentTest::onExit()
{
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
SceneEditorTestLayer::onExit();
}
cocos2d::Node* ParticleComponentTest::createGameScene()
{
_filePath = "scenetest/ParticleComponentTest/ParticleComponentTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
2014-06-25 14:32:38 +08:00
defaultPlay();
return _rootNode;
2014-06-25 14:32:38 +08:00
}
2014-06-25 14:32:38 +08:00
void ParticleComponentTest::defaultPlay()
{
ComRender* Particle = static_cast<ComRender*>(_rootNode->getChildByTag(10020)->getComponent("CCParticleSystemQuad"));
2014-06-25 14:32:38 +08:00
ActionInterval* jump = CCJumpBy::create(5, Point(-500,0), 50, 4);
FiniteTimeAction* action = CCSequence::create( jump, jump->reverse(), nullptr);
Particle->getNode()->runAction(action);
}
EffectComponentTest::EffectComponentTest()
{
}
EffectComponentTest::~EffectComponentTest()
{
}
std::string EffectComponentTest::title()
{
return "Effect Component Test";
}
void EffectComponentTest::onEnter()
{
SceneEditorTestLayer::onEnter();
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
this->addChild(root, 0, 1);
} while (0);
}
void EffectComponentTest::onExit()
{
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
SceneEditorTestLayer::onExit();
}
cocos2d::Node* EffectComponentTest::createGameScene()
{
_filePath = "scenetest/EffectComponentTest/EffectComponentTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
2014-06-25 14:32:38 +08:00
defaultPlay();
return _rootNode;
}
void EffectComponentTest::animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID)
2013-09-20 22:23:13 +08:00
{
std::string id = movementID;
if (movementType == LOOP_COMPLETE)
{
if (id.compare("Fire") == 0)
{
ComAudio *pAudio = static_cast<ComAudio*>(_rootNode->getChildByTag(10015)->getComponent("CCComAudio"));
pAudio->playEffect();
}
}
}
2014-06-25 14:32:38 +08:00
void EffectComponentTest::defaultPlay()
{
ComRender *render = static_cast<ComRender*>(_rootNode->getChildByTag(10015)->getComponent("CCArmature"));
2014-06-25 14:32:38 +08:00
Armature *pAr = static_cast<Armature*>(render->getNode());
pAr->getAnimation()->setMovementEventCallFunc(CC_CALLBACK_0(EffectComponentTest::animationEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
}
BackgroundComponentTest::BackgroundComponentTest()
{
}
BackgroundComponentTest::~BackgroundComponentTest()
{
}
std::string BackgroundComponentTest::title()
{
return "Background Component Test";
}
void BackgroundComponentTest::onEnter()
{
SceneEditorTestLayer::onEnter();
2013-09-20 22:23:13 +08:00
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
this->addChild(root, 0, 1);
} while (0);
}
2013-09-20 22:23:13 +08:00
void BackgroundComponentTest::onExit()
{
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
SceneEditorTestLayer::onExit();
}
cocos2d::Node* BackgroundComponentTest::createGameScene()
{
_filePath = "scenetest/BackgroundComponentTest/BackgroundComponentTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
2014-06-25 14:32:38 +08:00
defaultPlay();
return _rootNode;
2014-06-25 14:32:38 +08:00
}
2014-06-25 14:32:38 +08:00
void BackgroundComponentTest::defaultPlay()
{
ComAudio *Audio = static_cast<ComAudio*>(_rootNode->getComponent("CCBackgroundAudio"));
Audio->playBackgroundMusic();
}
AttributeComponentTest::AttributeComponentTest()
{
}
AttributeComponentTest::~AttributeComponentTest()
{
}
std::string AttributeComponentTest::title()
{
return "Attribute Component Test";
}
void AttributeComponentTest::onEnter()
{
SceneEditorTestLayer::onEnter();
do
{
Node *root = createGameScene();
CC_BREAK_IF(!root);
2014-06-25 14:32:38 +08:00
defaultPlay();
this->addChild(root, 0, 1);
2013-09-20 22:23:13 +08:00
} while (0);
}
2013-09-20 22:23:13 +08:00
void AttributeComponentTest::onExit()
{
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
SceneEditorTestLayer::onExit();
}
bool AttributeComponentTest::initData()
{
bool bRet = false;
rapidjson::Document doc;
do {
CC_BREAK_IF(_rootNode == nullptr);
ComAttribute *attribute = static_cast<ComAttribute*>(_rootNode->getChildByTag(10015)->getComponent("CCComAttribute"));
CC_BREAK_IF(attribute == nullptr);
log("Name: %s, HP: %f, MP: %f", attribute->getString("name").c_str(), attribute->getFloat("maxHP"), attribute->getFloat("maxMP"));
bRet = true;
} while (0);
2013-09-20 22:23:13 +08:00
return bRet;
}
cocos2d::Node* AttributeComponentTest::createGameScene()
{
_filePath = "scenetest/AttributeComponentTest/AttributeComponentTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
{
return nullptr;
}
return _rootNode;
2014-06-25 14:32:38 +08:00
}
void AttributeComponentTest::defaultPlay()
{
initData();
}
TriggerTest::TriggerTest()
: _node(nullptr)
, _touchListener(nullptr)
{
}
TriggerTest::~TriggerTest()
2013-12-26 01:17:04 +08:00
{
}
std::string TriggerTest::title()
{
return "Trigger Test";
}
// on "init" you need to initialize your instance
void TriggerTest::onEnter()
{
SceneEditorTestLayer::onEnter();
Node *root = createGameScene();
this->addChild(root, 0, 1);
this->schedule(schedule_selector(TriggerTest::gameLogic));
auto dispatcher = Director::getInstance()->getEventDispatcher();
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(SceneEditorTestLayer::onTouchBegan, this);
listener->onTouchMoved = CC_CALLBACK_2(SceneEditorTestLayer::onTouchMoved, this);
listener->onTouchEnded = CC_CALLBACK_2(SceneEditorTestLayer::onTouchEnded, this);
listener->onTouchCancelled = CC_CALLBACK_2(SceneEditorTestLayer::onTouchCancelled, this);
dispatcher->addEventListenerWithFixedPriority(listener, 1);
_touchListener = listener;
sendEvent(TRIGGEREVENT_ENTERSCENE);
}
void TriggerTest::onExit()
2013-12-26 01:17:04 +08:00
{
sendEvent(TRIGGEREVENT_LEAVESCENE);
this->unschedule(schedule_selector(TriggerTest::gameLogic));
auto dispatcher = Director::getInstance()->getEventDispatcher();
dispatcher->removeEventListener(_touchListener);
Device::setAccelerometerEnabled(false);
ArmatureDataManager::destroyInstance();
SceneReader::destroyInstance();
ActionManagerEx::destroyInstance();
GUIReader::destroyInstance();
SceneEditorTestLayer::onExit();
2013-12-26 01:17:04 +08:00
}
bool TriggerTest::onTouchBegan(Touch *touch, Event *unused_event)
2013-12-26 01:17:04 +08:00
{
sendEvent(TRIGGEREVENT_TOUCHBEGAN);
return true;
}
void TriggerTest::onTouchMoved(Touch *touch, Event *unused_event)
2013-12-26 01:17:04 +08:00
{
sendEvent(TRIGGEREVENT_TOUCHMOVED);
}
void TriggerTest::onTouchEnded(Touch *touch, Event *unused_event)
2013-12-26 01:17:04 +08:00
{
sendEvent(TRIGGEREVENT_TOUCHENDED);
}
void TriggerTest::onTouchCancelled(Touch *touch, Event *unused_event)
2013-12-26 01:17:04 +08:00
{
sendEvent(TRIGGEREVENT_TOUCHCANCELLED);
}
void TriggerTest::gameLogic(float dt)
2013-12-26 01:17:04 +08:00
{
sendEvent(TRIGGEREVENT_UPDATESCENE);
}
cocos2d::Node* TriggerTest::createGameScene()
2013-09-20 22:23:13 +08:00
{
_filePath = "scenetest/TriggerTest/TriggerTest.json";
_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str());
if (_rootNode == nullptr)
2013-09-20 22:23:13 +08:00
{
return nullptr;
2013-09-20 22:23:13 +08:00
}
2014-06-25 14:32:38 +08:00
defaultPlay();
return _rootNode;
2014-06-25 14:32:38 +08:00
}
void TriggerTest::defaultPlay()
{
2013-09-20 22:23:13 +08:00
}