mirror of https://github.com/axmolengine/axmol.git
1. add classname = "" log.
This commit is contained in:
parent
644b61e261
commit
bdf7be6fa0
|
@ -277,6 +277,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
|
||||||
}
|
}
|
||||||
const char *comName = DICTOOL->getStringValue_json(subDict, "classname");
|
const char *comName = DICTOOL->getStringValue_json(subDict, "classname");
|
||||||
Component *com = this->createComponent(comName);
|
Component *com = this->createComponent(comName);
|
||||||
|
CCLOG("classname = %s", comName);
|
||||||
SerData *data = new SerData();
|
SerData *data = new SerData();
|
||||||
if (com != nullptr)
|
if (com != nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,7 +106,7 @@ void SceneEditorTestScene::MainMenuCallback(Ref *pSender)
|
||||||
removeAllChildren();
|
removeAllChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* SceneEditorTestLayer::m_loadtypeStr[2] = {"change to load \nwith binary file","change to load \nwith json file"};
|
||||||
void SceneEditorTestLayer::onEnter()
|
void SceneEditorTestLayer::onEnter()
|
||||||
{
|
{
|
||||||
CCLayer::onEnter();
|
CCLayer::onEnter();
|
||||||
|
@ -127,6 +127,13 @@ void SceneEditorTestLayer::onEnter()
|
||||||
addChild(l, 1, 10001);
|
addChild(l, 1, 10001);
|
||||||
l->setPosition(Vec2(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
l->setPosition(Vec2(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
||||||
}
|
}
|
||||||
|
m_isCsbLoad = false;
|
||||||
|
m_loadtypelb = cocos2d::Label::createWithSystemFont(m_loadtypeStr[0], "Arial", 12);
|
||||||
|
// #endif
|
||||||
|
MenuItemLabel* itemlb = CCMenuItemLabel::create(m_loadtypelb, CC_CALLBACK_1(SceneEditorTestLayer::changeLoadTypeCallback, this));
|
||||||
|
Menu* loadtypemenu = CCMenu::create(itemlb, NULL);
|
||||||
|
loadtypemenu->setPosition(Point(VisibleRect::rightTop().x -50,VisibleRect::rightTop().y -20));
|
||||||
|
addChild(loadtypemenu,100);
|
||||||
|
|
||||||
// add menu
|
// add menu
|
||||||
backItem = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(SceneEditorTestLayer::backCallback, this) );
|
backItem = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(SceneEditorTestLayer::backCallback, this) );
|
||||||
|
@ -199,6 +206,36 @@ void SceneEditorTestLayer::draw(Renderer *renderer, const Mat4 &transform, uint3
|
||||||
Layer::draw(renderer, transform, flags);
|
Layer::draw(renderer, transform, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SceneEditorTestLayer::changeLoadTypeCallback(cocos2d::Ref *pSender)
|
||||||
|
{
|
||||||
|
m_isCsbLoad = !m_isCsbLoad;
|
||||||
|
m_loadtypelb->setString(m_loadtypeStr[(int)m_isCsbLoad]);
|
||||||
|
loadFileChangeHelper(m_filePathName);
|
||||||
|
|
||||||
|
if(m_rootNode != NULL)
|
||||||
|
{
|
||||||
|
this->removeChild(m_rootNode);
|
||||||
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
|
{
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
defaultPlay();
|
||||||
|
this->addChild(m_rootNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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(m_isCsbLoad)
|
||||||
|
filePathName.append(".csb");
|
||||||
|
else
|
||||||
|
filePathName.append(".json");
|
||||||
|
}
|
||||||
|
|
||||||
LoadSceneEdtiorFileTest::LoadSceneEdtiorFileTest()
|
LoadSceneEdtiorFileTest::LoadSceneEdtiorFileTest()
|
||||||
{
|
{
|
||||||
|
@ -238,12 +275,19 @@ void LoadSceneEdtiorFileTest::onExit()
|
||||||
|
|
||||||
cocos2d::Node* LoadSceneEdtiorFileTest::createGameScene()
|
cocos2d::Node* LoadSceneEdtiorFileTest::createGameScene()
|
||||||
{
|
{
|
||||||
Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/LoadSceneEdtiorFileTest/FishJoy2.csb");
|
m_filePathName = "scenetest/LoadSceneEdtiorFileTest/FishJoy2.json"; //default is json
|
||||||
if (node == nullptr)
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
return node;
|
defaultPlay();
|
||||||
|
return m_rootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadSceneEdtiorFileTest::defaultPlay()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SpriteComponentTest::SpriteComponentTest()
|
SpriteComponentTest::SpriteComponentTest()
|
||||||
|
@ -283,22 +327,29 @@ void SpriteComponentTest::onExit()
|
||||||
|
|
||||||
cocos2d::Node* SpriteComponentTest::createGameScene()
|
cocos2d::Node* SpriteComponentTest::createGameScene()
|
||||||
{
|
{
|
||||||
Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/SpriteComponentTest/SpriteComponentTest.csb");
|
m_filePathName = "scenetest/SpriteComponentTest/SpriteComponentTest.json";
|
||||||
if (node == nullptr)
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defaultPlay();
|
||||||
|
|
||||||
|
return m_rootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SpriteComponentTest::defaultPlay()
|
||||||
|
{
|
||||||
ActionInterval* action1 = CCBlink::create(2, 10);
|
ActionInterval* action1 = CCBlink::create(2, 10);
|
||||||
ActionInterval* action2 = CCBlink::create(2, 5);
|
ActionInterval* action2 = CCBlink::create(2, 5);
|
||||||
|
|
||||||
ComRender *pSister1 = static_cast<ComRender*>(node->getChildByTag(10003)->getComponent("CCSprite"));
|
ComRender *pSister1 = static_cast<ComRender*>(m_rootNode->getChildByTag(10003)->getComponent("CCSprite"));
|
||||||
pSister1->getNode()->runAction(action1);
|
pSister1->getNode()->runAction(action1);
|
||||||
|
|
||||||
ComRender *pSister2 = static_cast<ComRender*>(node->getChildByTag(10004)->getComponent("CCSprite"));
|
ComRender *pSister2 = static_cast<ComRender*>(m_rootNode->getChildByTag(10004)->getComponent("CCSprite"));
|
||||||
pSister2->getNode()->runAction(action2);
|
pSister2->getNode()->runAction(action2);
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArmatureComponentTest::ArmatureComponentTest()
|
ArmatureComponentTest::ArmatureComponentTest()
|
||||||
|
@ -338,22 +389,27 @@ void ArmatureComponentTest::onExit()
|
||||||
|
|
||||||
cocos2d::Node* ArmatureComponentTest::createGameScene()
|
cocos2d::Node* ArmatureComponentTest::createGameScene()
|
||||||
{
|
{
|
||||||
Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/ArmatureComponentTest/ArmatureComponentTest.csb");
|
m_filePathName = "scenetest/ArmatureComponentTest/ArmatureComponentTest.json";
|
||||||
if (node == nullptr)
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
ComRender *pBlowFish = static_cast<ComRender*>(node->getChildByTag(10007)->getComponent("CCArmature"));
|
defaultPlay();
|
||||||
pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0)));
|
return m_rootNode;
|
||||||
|
}
|
||||||
|
|
||||||
ComRender *pButterflyfish = static_cast<ComRender*>(node->getChildByTag(10008)->getComponent("CCArmature"));
|
void ArmatureComponentTest::defaultPlay()
|
||||||
pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0)));
|
{
|
||||||
|
ComRender *pBlowFish = static_cast<ComRender*>(m_rootNode->getChildByTag(10007)->getComponent("CCArmature"));
|
||||||
|
pBlowFish->getNode()->runAction(MoveBy::create(10.0f, Point(-1000.0f, 0)));
|
||||||
|
|
||||||
|
ComRender *pButterflyfish = static_cast<ComRender*>(m_rootNode->getChildByTag(10008)->getComponent("CCArmature"));
|
||||||
|
pButterflyfish->getNode()->runAction(MoveBy::create(10.0f, Point(-1000.0f, 0)));
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UIComponentTest::UIComponentTest()
|
UIComponentTest::UIComponentTest()
|
||||||
: _node(nullptr)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -389,20 +445,15 @@ void UIComponentTest::onExit()
|
||||||
|
|
||||||
cocos2d::Node* UIComponentTest::createGameScene()
|
cocos2d::Node* UIComponentTest::createGameScene()
|
||||||
{
|
{
|
||||||
Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/UIComponentTest/UIComponentTest.csb");
|
m_filePathName = "scenetest/UIComponentTest/UIComponentTest.json";
|
||||||
if (node == nullptr)
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
_node = node;
|
defaultPlay();
|
||||||
|
|
||||||
ComRender *render = static_cast<ComRender*>(_node->getChildByTag(10025)->getComponent("GUIComponent"));
|
return m_rootNode;
|
||||||
Widget* widget = static_cast<cocos2d::ui::Widget*>(render->getNode());
|
|
||||||
Button* button = static_cast<Button*>(widget->getChildByName("Button_156"));
|
|
||||||
// button->addTouchEventListener(this, toucheventselector(UIComponentTest::touchEvent));
|
|
||||||
button->addTouchEventListener(CC_CALLBACK_2(UIComponentTest::touchEvent, this));
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIComponentTest::touchEvent(Ref *pSender, ui::Widget::TouchEventType type)
|
void UIComponentTest::touchEvent(Ref *pSender, ui::Widget::TouchEventType type)
|
||||||
|
@ -411,10 +462,10 @@ void UIComponentTest::touchEvent(Ref *pSender, ui::Widget::TouchEventType type)
|
||||||
{
|
{
|
||||||
case ui::Widget::TouchEventType::BEGAN:
|
case ui::Widget::TouchEventType::BEGAN:
|
||||||
{
|
{
|
||||||
ComRender *pBlowFish = static_cast<ComRender*>(_node->getChildByTag(10010)->getComponent("CCArmature"));
|
ComRender *pBlowFish = static_cast<ComRender*>(m_rootNode->getChildByTag(10010)->getComponent("CCArmature"));
|
||||||
pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0)));
|
pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0)));
|
||||||
|
|
||||||
ComRender *pButterflyfish = static_cast<ComRender*>(_node->getChildByTag(10011)->getComponent("CCArmature"));
|
ComRender *pButterflyfish = static_cast<ComRender*>(m_rootNode->getChildByTag(10011)->getComponent("CCArmature"));
|
||||||
pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0)));
|
pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, Vec2(-1000.0f, 0)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -423,6 +474,15 @@ void UIComponentTest::touchEvent(Ref *pSender, ui::Widget::TouchEventType type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIComponentTest::defaultPlay()
|
||||||
|
{
|
||||||
|
|
||||||
|
ComRender *render = static_cast<ComRender*>(m_rootNode->getChildByTag(10025)->getComponent("GUIComponent"));
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -460,24 +520,30 @@ void TmxMapComponentTest::onExit()
|
||||||
|
|
||||||
cocos2d::Node* TmxMapComponentTest::createGameScene()
|
cocos2d::Node* TmxMapComponentTest::createGameScene()
|
||||||
{
|
{
|
||||||
Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/TmxMapComponentTest/TmxMapComponentTest.csb");
|
m_filePathName = "scenetest/TmxMapComponentTest/TmxMapComponentTest.json";
|
||||||
if (node == nullptr)
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
ComRender *tmxMap = static_cast<ComRender*>(node->getChildByTag(10015)->getComponent("CCTMXTiledMap"));
|
defaultPlay();
|
||||||
ActionInterval *actionTo = SkewTo::create(2, 0.f, 2.f);
|
return m_rootNode;
|
||||||
ActionInterval *rotateTo = RotateTo::create(2, 61.0f);
|
}
|
||||||
ActionInterval *actionScaleTo = ScaleTo::create(2, -0.44f, 0.47f);
|
|
||||||
|
|
||||||
ActionInterval *actionScaleToBack = ScaleTo::create(2, 1.0f, 1.0f);
|
void TmxMapComponentTest::defaultPlay()
|
||||||
ActionInterval *rotateToBack = RotateTo::create(2, 0);
|
{
|
||||||
ActionInterval *actionToBack = SkewTo::create(2, 0, 0);
|
ComRender *tmxMap = static_cast<ComRender*>(m_rootNode->getChildByTag(10015)->getComponent("CCTMXTiledMap"));
|
||||||
|
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);
|
||||||
|
|
||||||
tmxMap->getNode()->runAction(Sequence::create(actionTo, actionToBack, nullptr));
|
ActionInterval *actionScaleToBack = CCScaleTo::create(2, 1.0f, 1.0f);
|
||||||
tmxMap->getNode()->runAction(Sequence::create(rotateTo, rotateToBack, nullptr));
|
ActionInterval *rotateToBack = CCRotateTo::create(2, 0);
|
||||||
tmxMap->getNode()->runAction(Sequence::create(actionScaleTo, actionScaleToBack, nullptr));
|
ActionInterval *actionToBack = CCSkewTo::create(2, 0, 0);
|
||||||
return node;
|
|
||||||
|
tmxMap->getNode()->runAction(CCSequence::create(actionTo, actionToBack, NULL));
|
||||||
|
tmxMap->getNode()->runAction(CCSequence::create(rotateTo, rotateToBack, NULL));
|
||||||
|
tmxMap->getNode()->runAction(CCSequence::create(actionScaleTo, actionScaleToBack, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleComponentTest::ParticleComponentTest()
|
ParticleComponentTest::ParticleComponentTest()
|
||||||
|
@ -516,22 +582,26 @@ void ParticleComponentTest::onExit()
|
||||||
|
|
||||||
cocos2d::Node* ParticleComponentTest::createGameScene()
|
cocos2d::Node* ParticleComponentTest::createGameScene()
|
||||||
{
|
{
|
||||||
Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/ParticleComponentTest/ParticleComponentTest.csb");
|
m_filePathName = "scenetest/ParticleComponentTest/ParticleComponentTest.json";
|
||||||
if (node == nullptr)
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
defaultPlay();
|
||||||
|
return m_rootNode;
|
||||||
|
}
|
||||||
|
|
||||||
ComRender* Particle = static_cast<ComRender*>(node->getChildByTag(10020)->getComponent("CCParticleSystemQuad"));
|
void ParticleComponentTest::defaultPlay()
|
||||||
ActionInterval* jump = JumpBy::create(5, Vec2(-500,0), 50, 4);
|
{
|
||||||
FiniteTimeAction* action = Sequence::create( jump, jump->reverse(), nullptr);
|
ComRender* Particle = static_cast<ComRender*>(m_rootNode->getChildByTag(10020)->getComponent("CCParticleSystemQuad"));
|
||||||
|
ActionInterval* jump = CCJumpBy::create(5, Point(-500,0), 50, 4);
|
||||||
|
FiniteTimeAction* action = CCSequence::create( jump, jump->reverse(), NULL);
|
||||||
Particle->getNode()->runAction(action);
|
Particle->getNode()->runAction(action);
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EffectComponentTest::EffectComponentTest()
|
EffectComponentTest::EffectComponentTest()
|
||||||
: _node(nullptr)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -567,16 +637,14 @@ void EffectComponentTest::onExit()
|
||||||
|
|
||||||
cocos2d::Node* EffectComponentTest::createGameScene()
|
cocos2d::Node* EffectComponentTest::createGameScene()
|
||||||
{
|
{
|
||||||
Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/EffectComponentTest/EffectComponentTest.csb");
|
m_filePathName = "scenetest/EffectComponentTest/EffectComponentTest.json";
|
||||||
if (node == nullptr)
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
_node = node;
|
defaultPlay();
|
||||||
ComRender *render = static_cast<ComRender*>(_node->getChildByTag(10015)->getComponent("CCArmature"));
|
return m_rootNode;
|
||||||
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));
|
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectComponentTest::animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID)
|
void EffectComponentTest::animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID)
|
||||||
|
@ -587,12 +655,19 @@ void EffectComponentTest::animationEvent(Armature *armature, MovementEventType m
|
||||||
{
|
{
|
||||||
if (id.compare("Fire") == 0)
|
if (id.compare("Fire") == 0)
|
||||||
{
|
{
|
||||||
ComAudio *pAudio = static_cast<ComAudio*>(_node->getChildByTag(10015)->getComponent("CCComAudio"));
|
ComAudio *pAudio = static_cast<ComAudio*>(m_rootNode->getChildByTag(10015)->getComponent("CCComAudio"));
|
||||||
pAudio->playEffect();
|
pAudio->playEffect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EffectComponentTest::defaultPlay()
|
||||||
|
{
|
||||||
|
ComRender *render = static_cast<ComRender*>(m_rootNode->getChildByTag(10015)->getComponent("CCArmature"));
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -629,20 +704,24 @@ void BackgroundComponentTest::onExit()
|
||||||
|
|
||||||
cocos2d::Node* BackgroundComponentTest::createGameScene()
|
cocos2d::Node* BackgroundComponentTest::createGameScene()
|
||||||
{
|
{
|
||||||
Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/BackgroundComponentTest/BackgroundComponentTest.csb");
|
m_filePathName = "scenetest/BackgroundComponentTest/BackgroundComponentTest.json";
|
||||||
if (node == nullptr)
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
defaultPlay();
|
||||||
|
return m_rootNode;
|
||||||
|
}
|
||||||
|
|
||||||
ComAudio *Audio = static_cast<ComAudio*>(node->getComponent("CCBackgroundAudio"));
|
void BackgroundComponentTest::defaultPlay()
|
||||||
|
{
|
||||||
|
ComAudio *Audio = static_cast<ComAudio*>(m_rootNode->getComponent("CCBackgroundAudio"));
|
||||||
Audio->playBackgroundMusic();
|
Audio->playBackgroundMusic();
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AttributeComponentTest::AttributeComponentTest()
|
AttributeComponentTest::AttributeComponentTest()
|
||||||
: _node(nullptr)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -663,7 +742,7 @@ void AttributeComponentTest::onEnter()
|
||||||
{
|
{
|
||||||
Node *root = createGameScene();
|
Node *root = createGameScene();
|
||||||
CC_BREAK_IF(!root);
|
CC_BREAK_IF(!root);
|
||||||
initData();
|
defaultPlay();
|
||||||
this->addChild(root, 0, 1);
|
this->addChild(root, 0, 1);
|
||||||
} while (0);
|
} while (0);
|
||||||
}
|
}
|
||||||
|
@ -682,8 +761,8 @@ bool AttributeComponentTest::initData()
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
rapidjson::Document doc;
|
rapidjson::Document doc;
|
||||||
do {
|
do {
|
||||||
CC_BREAK_IF(_node == nullptr);
|
CC_BREAK_IF(m_rootNode == nullptr);
|
||||||
ComAttribute *attribute = static_cast<ComAttribute*>(_node->getChildByTag(10015)->getComponent("CCComAttribute"));
|
ComAttribute *attribute = static_cast<ComAttribute*>(m_rootNode->getChildByTag(10015)->getComponent("CCComAttribute"));
|
||||||
CC_BREAK_IF(attribute == nullptr);
|
CC_BREAK_IF(attribute == nullptr);
|
||||||
log("Name: %s, HP: %f, MP: %f", attribute->getString("name").c_str(), attribute->getFloat("maxHP"), attribute->getFloat("maxMP"));
|
log("Name: %s, HP: %f, MP: %f", attribute->getString("name").c_str(), attribute->getFloat("maxHP"), attribute->getFloat("maxMP"));
|
||||||
|
|
||||||
|
@ -694,13 +773,18 @@ bool AttributeComponentTest::initData()
|
||||||
|
|
||||||
cocos2d::Node* AttributeComponentTest::createGameScene()
|
cocos2d::Node* AttributeComponentTest::createGameScene()
|
||||||
{
|
{
|
||||||
Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/AttributeComponentTest/AttributeComponentTest.csb");
|
m_filePathName = "scenetest/AttributeComponentTest/AttributeComponentTest.json";
|
||||||
if (node == nullptr)
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
_node = node;
|
return m_rootNode;
|
||||||
return node;
|
}
|
||||||
|
|
||||||
|
void AttributeComponentTest::defaultPlay()
|
||||||
|
{
|
||||||
|
initData();
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerTest::TriggerTest()
|
TriggerTest::TriggerTest()
|
||||||
|
@ -783,12 +867,16 @@ void TriggerTest::gameLogic(float dt)
|
||||||
|
|
||||||
cocos2d::Node* TriggerTest::createGameScene()
|
cocos2d::Node* TriggerTest::createGameScene()
|
||||||
{
|
{
|
||||||
Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/TriggerTest/TriggerTest.csb");
|
m_filePathName = "scenetest/TriggerTest/TriggerTest.json";
|
||||||
if (node == nullptr)
|
m_rootNode = SceneReader::getInstance()->createNodeWithSceneFile(m_filePathName.c_str());
|
||||||
|
if (m_rootNode == NULL)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
_node = node;
|
|
||||||
|
defaultPlay();
|
||||||
return node;
|
return m_rootNode;
|
||||||
|
}
|
||||||
|
void TriggerTest::defaultPlay()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,20 @@ protected:
|
||||||
MenuItemImage *restartItem;
|
MenuItemImage *restartItem;
|
||||||
MenuItemImage *nextItem;
|
MenuItemImage *nextItem;
|
||||||
MenuItemImage *backItem;
|
MenuItemImage *backItem;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void changeLoadTypeCallback(cocos2d::Ref *pSender);
|
||||||
|
virtual void defaultPlay() = 0; // must to be overrided
|
||||||
|
void loadFileChangeHelper(std::string& filePathName ); // switch json& csb
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_isCsbLoad; // default is false
|
||||||
|
cocos2d::Label* m_loadtypelb;
|
||||||
|
static const char* m_loadtypeStr[2];
|
||||||
|
|
||||||
|
protected:
|
||||||
|
cocos2d::Node* m_rootNode;
|
||||||
|
std::string m_filePathName;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LoadSceneEdtiorFileTest : public SceneEditorTestLayer
|
class LoadSceneEdtiorFileTest : public SceneEditorTestLayer
|
||||||
|
@ -61,6 +75,8 @@ public:
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
cocos2d::Node* createGameScene();
|
cocos2d::Node* createGameScene();
|
||||||
|
private:
|
||||||
|
void defaultPlay();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,6 +91,8 @@ public:
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
cocos2d::Node* createGameScene();
|
cocos2d::Node* createGameScene();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void defaultPlay();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ArmatureComponentTest : public SceneEditorTestLayer
|
class ArmatureComponentTest : public SceneEditorTestLayer
|
||||||
|
@ -88,6 +106,8 @@ public:
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
cocos2d::Node* createGameScene();
|
cocos2d::Node* createGameScene();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void defaultPlay();
|
||||||
};
|
};
|
||||||
|
|
||||||
class UIComponentTest : public SceneEditorTestLayer
|
class UIComponentTest : public SceneEditorTestLayer
|
||||||
|
@ -102,7 +122,7 @@ public:
|
||||||
cocos2d::Node* createGameScene();
|
cocos2d::Node* createGameScene();
|
||||||
void touchEvent(cocos2d::Ref *pSender, ui::Widget::TouchEventType type);
|
void touchEvent(cocos2d::Ref *pSender, ui::Widget::TouchEventType type);
|
||||||
private:
|
private:
|
||||||
cocos2d::Node* _node;
|
void defaultPlay();
|
||||||
};
|
};
|
||||||
|
|
||||||
class TmxMapComponentTest : public SceneEditorTestLayer
|
class TmxMapComponentTest : public SceneEditorTestLayer
|
||||||
|
@ -115,6 +135,8 @@ public:
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
cocos2d::Node* createGameScene();
|
cocos2d::Node* createGameScene();
|
||||||
|
private:
|
||||||
|
void defaultPlay();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,6 +150,8 @@ public:
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
cocos2d::Node* createGameScene();
|
cocos2d::Node* createGameScene();
|
||||||
|
protected:
|
||||||
|
void defaultPlay();
|
||||||
};
|
};
|
||||||
|
|
||||||
class EffectComponentTest : public SceneEditorTestLayer
|
class EffectComponentTest : public SceneEditorTestLayer
|
||||||
|
@ -142,7 +166,8 @@ public:
|
||||||
cocos2d::Node* createGameScene();
|
cocos2d::Node* createGameScene();
|
||||||
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID);
|
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID);
|
||||||
private:
|
private:
|
||||||
cocos2d::Node* _node;
|
void defaultPlay();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class BackgroundComponentTest : public SceneEditorTestLayer
|
class BackgroundComponentTest : public SceneEditorTestLayer
|
||||||
|
@ -155,6 +180,8 @@ public:
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
cocos2d::Node* createGameScene();
|
cocos2d::Node* createGameScene();
|
||||||
|
private:
|
||||||
|
void defaultPlay();
|
||||||
};
|
};
|
||||||
|
|
||||||
class AttributeComponentTest : public SceneEditorTestLayer
|
class AttributeComponentTest : public SceneEditorTestLayer
|
||||||
|
@ -168,8 +195,9 @@ public:
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
bool initData();
|
bool initData();
|
||||||
cocos2d::Node* createGameScene();
|
cocos2d::Node* createGameScene();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cocos2d::Node* _node;
|
void defaultPlay();
|
||||||
};
|
};
|
||||||
|
|
||||||
class TriggerTest : public SceneEditorTestLayer
|
class TriggerTest : public SceneEditorTestLayer
|
||||||
|
@ -197,6 +225,8 @@ public:
|
||||||
private:
|
private:
|
||||||
cocos2d::Node *_node;
|
cocos2d::Node *_node;
|
||||||
cocos2d::EventListener* _touchListener;
|
cocos2d::EventListener* _touchListener;
|
||||||
|
private:
|
||||||
|
void defaultPlay();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __HELLOWORLD_SCENE_H__
|
#endif // __HELLOWORLD_SCENE_H__
|
||||||
|
|
Loading…
Reference in New Issue