2013-09-20 22:23:13 +08:00
|
|
|
#ifndef __SCENEEDITORTESTSCENE_H__
|
|
|
|
#define __SCENEEDITORTESTSCENE_H__
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "extensions/cocos-ext.h"
|
2014-01-03 01:42:14 +08:00
|
|
|
#include "cocostudio/CocoStudio.h"
|
2015-04-03 14:31:03 +08:00
|
|
|
#include "BaseTest.h"
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(CocoStudioSceneEditTests);
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class SceneEditorTestBase : public TestCase
|
2013-09-20 22:23:13 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual bool init() override;
|
2014-01-03 01:14:12 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-01-03 01:14:12 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
MenuItemImage *restartItem;
|
|
|
|
MenuItemImage *nextItem;
|
|
|
|
MenuItemImage *backItem;
|
2014-06-25 14:32:38 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void changeLoadTypeCallback(cocos2d::Ref *pSender);
|
|
|
|
virtual void defaultPlay() = 0; // must to be overrided
|
|
|
|
void loadFileChangeHelper(std::string& filePathName ); // switch json& csb
|
|
|
|
|
|
|
|
private:
|
2014-06-26 10:08:17 +08:00
|
|
|
bool _isCsbLoad; // default is false
|
|
|
|
cocos2d::Label* _loadtypelb;
|
|
|
|
static const char* _loadtypeStr[2];
|
2014-06-25 14:32:38 +08:00
|
|
|
|
|
|
|
protected:
|
2014-06-26 10:08:17 +08:00
|
|
|
cocos2d::Node* _rootNode;
|
|
|
|
std::string _filePath;
|
2014-01-03 01:14:12 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class LoadSceneEdtiorFileTest : public SceneEditorTestBase
|
2014-01-03 01:14:12 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(LoadSceneEdtiorFileTest);
|
|
|
|
|
2014-01-03 20:33:07 +08:00
|
|
|
LoadSceneEdtiorFileTest();
|
|
|
|
~LoadSceneEdtiorFileTest();
|
2014-01-03 01:14:12 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-01-03 01:14:12 +08:00
|
|
|
cocos2d::Node* createGameScene();
|
2014-06-25 14:32:38 +08:00
|
|
|
private:
|
|
|
|
void defaultPlay();
|
2014-01-03 01:14:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class SpriteComponentTest : public SceneEditorTestBase
|
2014-01-03 01:14:12 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(SpriteComponentTest);
|
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
SpriteComponentTest();
|
|
|
|
~SpriteComponentTest();
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-01-03 01:14:12 +08:00
|
|
|
cocos2d::Node* createGameScene();
|
|
|
|
|
2014-06-25 14:32:38 +08:00
|
|
|
private:
|
|
|
|
void defaultPlay();
|
2014-01-03 01:14:12 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class ArmatureComponentTest : public SceneEditorTestBase
|
2014-01-03 01:14:12 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(ArmatureComponentTest);
|
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
ArmatureComponentTest();
|
|
|
|
~ArmatureComponentTest();
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-01-03 01:14:12 +08:00
|
|
|
cocos2d::Node* createGameScene();
|
|
|
|
|
2014-06-25 14:32:38 +08:00
|
|
|
private:
|
|
|
|
void defaultPlay();
|
2014-01-03 01:14:12 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class UIComponentTest : public SceneEditorTestBase
|
2014-01-03 01:14:12 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(UIComponentTest);
|
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
UIComponentTest();
|
|
|
|
~UIComponentTest();
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-01-03 01:14:12 +08:00
|
|
|
cocos2d::Node* createGameScene();
|
2014-05-09 14:30:39 +08:00
|
|
|
void touchEvent(cocos2d::Ref *pSender, ui::Widget::TouchEventType type);
|
2014-01-03 01:14:12 +08:00
|
|
|
private:
|
2014-06-25 14:32:38 +08:00
|
|
|
void defaultPlay();
|
2014-01-03 01:14:12 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class TmxMapComponentTest : public SceneEditorTestBase
|
2014-01-03 01:14:12 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(TmxMapComponentTest);
|
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
TmxMapComponentTest();
|
|
|
|
~TmxMapComponentTest();
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-01-03 01:14:12 +08:00
|
|
|
cocos2d::Node* createGameScene();
|
2014-06-25 14:32:38 +08:00
|
|
|
private:
|
|
|
|
void defaultPlay();
|
2014-01-03 01:14:12 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class ParticleComponentTest : public SceneEditorTestBase
|
2014-01-03 01:14:12 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(ParticleComponentTest);
|
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
ParticleComponentTest();
|
|
|
|
~ParticleComponentTest();
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-01-03 01:14:12 +08:00
|
|
|
cocos2d::Node* createGameScene();
|
2014-06-25 14:32:38 +08:00
|
|
|
protected:
|
|
|
|
void defaultPlay();
|
2014-01-03 01:14:12 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class EffectComponentTest : public SceneEditorTestBase
|
2014-01-03 01:14:12 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(EffectComponentTest);
|
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
EffectComponentTest();
|
|
|
|
~EffectComponentTest();
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-01-03 01:14:12 +08:00
|
|
|
cocos2d::Node* createGameScene();
|
|
|
|
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID);
|
|
|
|
private:
|
2014-06-25 14:32:38 +08:00
|
|
|
void defaultPlay();
|
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class BackgroundComponentTest : public SceneEditorTestBase
|
2014-01-03 01:14:12 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(BackgroundComponentTest);
|
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
BackgroundComponentTest();
|
|
|
|
~BackgroundComponentTest();
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-01-03 01:14:12 +08:00
|
|
|
cocos2d::Node* createGameScene();
|
2014-06-25 14:32:38 +08:00
|
|
|
private:
|
|
|
|
void defaultPlay();
|
2014-01-03 01:14:12 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class AttributeComponentTest : public SceneEditorTestBase
|
2014-01-03 01:14:12 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(AttributeComponentTest);
|
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
AttributeComponentTest();
|
|
|
|
~AttributeComponentTest();
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-01-03 01:14:12 +08:00
|
|
|
bool initData();
|
|
|
|
cocos2d::Node* createGameScene();
|
2014-06-25 14:32:38 +08:00
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
private:
|
2014-06-25 14:32:38 +08:00
|
|
|
void defaultPlay();
|
2014-01-03 01:14:12 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class TriggerTest : public SceneEditorTestBase
|
2014-01-03 01:14:12 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(TriggerTest);
|
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
TriggerTest();
|
|
|
|
~TriggerTest();
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2013-12-26 01:17:04 +08:00
|
|
|
|
|
|
|
// default implements are used to call script callback if exist
|
|
|
|
virtual bool onTouchBegan(Touch *touch, Event *unused_event);
|
|
|
|
virtual void onTouchMoved(Touch *touch, Event *unused_event);
|
|
|
|
virtual void onTouchEnded(Touch *touch, Event *unused_event);
|
|
|
|
virtual void onTouchCancelled(Touch *touch, Event *unused_event);
|
|
|
|
|
|
|
|
// update of game
|
|
|
|
void gameLogic(float dt);
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2014-01-03 01:14:12 +08:00
|
|
|
// create scene
|
2013-09-20 22:23:13 +08:00
|
|
|
cocos2d::Node* createGameScene();
|
2014-01-03 01:14:12 +08:00
|
|
|
|
2013-09-20 22:23:13 +08:00
|
|
|
private:
|
2014-11-26 09:53:52 +08:00
|
|
|
void defaultPlay();
|
|
|
|
|
2013-12-26 01:17:04 +08:00
|
|
|
cocos2d::EventListener* _touchListener;
|
2013-09-20 22:23:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __HELLOWORLD_SCENE_H__
|