mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4812 from ricardoquesada/node_test_fixes
NodeTest converted to lambda functions
This commit is contained in:
commit
f5fa5cbff4
|
@ -22,40 +22,33 @@ Layer* restartCocosNodeAction();
|
|||
|
||||
static int sceneIdx = -1;
|
||||
|
||||
#define MAX_LAYER 14
|
||||
|
||||
Layer* createCocosNodeLayer(int nIndex)
|
||||
static std::function<Layer*()> createFunctions[] =
|
||||
{
|
||||
switch(nIndex)
|
||||
{
|
||||
case 0: return new CameraCenterTest();
|
||||
case 1: return new Test2();
|
||||
case 2: return new Test4();
|
||||
case 3: return new Test5();
|
||||
case 4: return new Test6();
|
||||
case 5: return new StressTest1();
|
||||
case 6: return new StressTest2();
|
||||
case 7: return new NodeToWorld();
|
||||
case 8: return new SchedulerTest1();
|
||||
case 9: return new CameraOrbitTest();
|
||||
case 10: return new CameraZoomTest();
|
||||
case 11: return new ConvertToNode();
|
||||
case 12: return new NodeOpaqueTest();
|
||||
case 13: return new NodeNonOpaqueTest();
|
||||
}
|
||||
CL(CameraCenterTest),
|
||||
CL(Test2),
|
||||
CL(Test4),
|
||||
CL(Test5),
|
||||
CL(Test6),
|
||||
CL(StressTest1),
|
||||
CL(StressTest2),
|
||||
CL(NodeToWorld),
|
||||
CL(SchedulerTest1),
|
||||
CL(CameraOrbitTest),
|
||||
CL(CameraZoomTest),
|
||||
CL(ConvertToNode),
|
||||
CL(NodeOpaqueTest),
|
||||
CL(NodeNonOpaqueTest),
|
||||
};
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
||||
|
||||
Layer* nextCocosNodeAction()
|
||||
{
|
||||
sceneIdx++;
|
||||
sceneIdx = sceneIdx % MAX_LAYER;
|
||||
|
||||
auto layer = createCocosNodeLayer(sceneIdx);
|
||||
layer->autorelease();
|
||||
|
||||
return layer;
|
||||
return createFunctions[sceneIdx]();
|
||||
}
|
||||
|
||||
Layer* backCocosNodeAction()
|
||||
|
@ -65,18 +58,12 @@ Layer* backCocosNodeAction()
|
|||
if( sceneIdx < 0 )
|
||||
sceneIdx += total;
|
||||
|
||||
auto layer = createCocosNodeLayer(sceneIdx);
|
||||
layer->autorelease();
|
||||
|
||||
return layer;
|
||||
return createFunctions[sceneIdx]();
|
||||
}
|
||||
|
||||
Layer* restartCocosNodeAction()
|
||||
{
|
||||
auto layer = createCocosNodeLayer(sceneIdx);
|
||||
layer->autorelease();
|
||||
|
||||
return layer;
|
||||
return createFunctions[sceneIdx]();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
class TestCocosNodeDemo : public BaseTest
|
||||
{
|
||||
public:
|
||||
TestCocosNodeDemo(void);
|
||||
~TestCocosNodeDemo(void);
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
@ -18,11 +16,16 @@ public:
|
|||
void restartCallback(Object* sender);
|
||||
void nextCallback(Object* sender);
|
||||
void backCallback(Object* sender);
|
||||
|
||||
protected:
|
||||
TestCocosNodeDemo();
|
||||
virtual ~TestCocosNodeDemo();
|
||||
};
|
||||
|
||||
class Test2 : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Test2);
|
||||
virtual void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
@ -30,120 +33,153 @@ public:
|
|||
class Test4 : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
Test4();
|
||||
CREATE_FUNC(Test4);
|
||||
void delay2(float dt);
|
||||
void delay4(float dt);
|
||||
|
||||
virtual std::string title() const override;
|
||||
|
||||
protected:
|
||||
Test4();
|
||||
};
|
||||
|
||||
class Test5 : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
Test5();
|
||||
void addAndRemove(float dt);
|
||||
CREATE_FUNC(Test5);
|
||||
|
||||
void addAndRemove(float dt);
|
||||
virtual std::string title() const override;
|
||||
|
||||
protected:
|
||||
Test5();
|
||||
};
|
||||
|
||||
class Test6 : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
Test6();
|
||||
CREATE_FUNC(Test6);
|
||||
void addAndRemove(float dt);
|
||||
|
||||
virtual std::string title() const override;
|
||||
|
||||
protected:
|
||||
Test6();
|
||||
};
|
||||
|
||||
class StressTest1 : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(StressTest1);
|
||||
void shouldNotCrash(float dt);
|
||||
void removeMe(Node* node);
|
||||
public:
|
||||
StressTest1();
|
||||
|
||||
virtual std::string title() const override;
|
||||
|
||||
protected:
|
||||
StressTest1();
|
||||
};
|
||||
|
||||
class StressTest2 : public TestCocosNodeDemo
|
||||
{
|
||||
void shouldNotLeak(float dt);
|
||||
public:
|
||||
StressTest2();
|
||||
|
||||
CREATE_FUNC(StressTest2);
|
||||
void shouldNotLeak(float dt);
|
||||
virtual std::string title() const override;
|
||||
|
||||
protected:
|
||||
StressTest2();
|
||||
};
|
||||
|
||||
class SchedulerTest1 : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
SchedulerTest1();
|
||||
CREATE_FUNC(SchedulerTest1);
|
||||
void doSomething(float dt);
|
||||
|
||||
virtual std::string title() const override;
|
||||
|
||||
protected:
|
||||
SchedulerTest1();
|
||||
};
|
||||
|
||||
class NodeToWorld : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
NodeToWorld();
|
||||
CREATE_FUNC(NodeToWorld);
|
||||
virtual std::string title() const override;
|
||||
|
||||
protected:
|
||||
NodeToWorld();
|
||||
};
|
||||
|
||||
class CameraOrbitTest : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
CameraOrbitTest();
|
||||
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
CREATE_FUNC(CameraOrbitTest);
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
virtual std::string title() const override;
|
||||
|
||||
protected:
|
||||
CameraOrbitTest();
|
||||
};
|
||||
|
||||
class CameraZoomTest : public TestCocosNodeDemo
|
||||
{
|
||||
float _z;
|
||||
public:
|
||||
CameraZoomTest();
|
||||
CREATE_FUNC(CameraZoomTest);
|
||||
void update(float dt);
|
||||
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
virtual std::string title() const override;
|
||||
|
||||
protected:
|
||||
CameraZoomTest();
|
||||
float _z;
|
||||
};
|
||||
|
||||
class CameraCenterTest : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
CameraCenterTest();
|
||||
CREATE_FUNC(CameraCenterTest);
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
CameraCenterTest();
|
||||
};
|
||||
|
||||
class ConvertToNode : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
ConvertToNode();
|
||||
CREATE_FUNC(ConvertToNode);
|
||||
void onTouchesEnded(const std::vector<Touch*>& touches, Event *event);
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
ConvertToNode();
|
||||
};
|
||||
|
||||
class NodeOpaqueTest : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
NodeOpaqueTest();
|
||||
CREATE_FUNC(NodeOpaqueTest);
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
NodeOpaqueTest();
|
||||
};
|
||||
|
||||
class NodeNonOpaqueTest : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
NodeNonOpaqueTest();
|
||||
CREATE_FUNC(NodeNonOpaqueTest);
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
NodeNonOpaqueTest();
|
||||
};
|
||||
|
||||
class CocosNodeTestScene : public TestScene
|
||||
|
|
|
@ -37,7 +37,7 @@ protected:
|
|||
|
||||
public:
|
||||
SpriteTestDemo(void);
|
||||
~SpriteTestDemo(void);
|
||||
virtual ~SpriteTestDemo(void);
|
||||
|
||||
void restartCallback(Object* sender);
|
||||
void nextCallback(Object* sender);
|
||||
|
@ -383,7 +383,7 @@ class SpriteOffsetAnchorSkew : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteOffsetAnchorSkew);
|
||||
SpriteOffsetAnchorSkew();
|
||||
~SpriteOffsetAnchorSkew();
|
||||
virtual ~SpriteOffsetAnchorSkew();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -393,7 +393,7 @@ class SpriteOffsetAnchorRotationalSkew : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteOffsetAnchorRotationalSkew);
|
||||
SpriteOffsetAnchorRotationalSkew();
|
||||
~SpriteOffsetAnchorRotationalSkew();
|
||||
virtual ~SpriteOffsetAnchorRotationalSkew();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -403,7 +403,7 @@ class SpriteBatchNodeOffsetAnchorSkew : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteBatchNodeOffsetAnchorSkew);
|
||||
SpriteBatchNodeOffsetAnchorSkew();
|
||||
~SpriteBatchNodeOffsetAnchorSkew();
|
||||
virtual ~SpriteBatchNodeOffsetAnchorSkew();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -413,7 +413,7 @@ class SpriteOffsetAnchorRotationalSkewScale : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteOffsetAnchorRotationalSkewScale);
|
||||
SpriteOffsetAnchorRotationalSkewScale();
|
||||
~SpriteOffsetAnchorRotationalSkewScale();
|
||||
virtual ~SpriteOffsetAnchorRotationalSkewScale();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -423,7 +423,7 @@ class SpriteBatchNodeOffsetAnchorRotationalSkew : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteBatchNodeOffsetAnchorRotationalSkew);
|
||||
SpriteBatchNodeOffsetAnchorRotationalSkew();
|
||||
~SpriteBatchNodeOffsetAnchorRotationalSkew();
|
||||
virtual ~SpriteBatchNodeOffsetAnchorRotationalSkew();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -433,7 +433,7 @@ class SpriteOffsetAnchorSkewScale : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteOffsetAnchorSkewScale);
|
||||
SpriteOffsetAnchorSkewScale();
|
||||
~SpriteOffsetAnchorSkewScale();
|
||||
virtual ~SpriteOffsetAnchorSkewScale();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -443,7 +443,7 @@ class SpriteBatchNodeOffsetAnchorSkewScale : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteBatchNodeOffsetAnchorSkewScale);
|
||||
SpriteBatchNodeOffsetAnchorSkewScale();
|
||||
~SpriteBatchNodeOffsetAnchorSkewScale();
|
||||
virtual ~SpriteBatchNodeOffsetAnchorSkewScale();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -453,7 +453,7 @@ class SpriteBatchNodeOffsetAnchorRotationalSkewScale : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteBatchNodeOffsetAnchorRotationalSkewScale);
|
||||
SpriteBatchNodeOffsetAnchorRotationalSkewScale();
|
||||
~SpriteBatchNodeOffsetAnchorRotationalSkewScale();
|
||||
virtual ~SpriteBatchNodeOffsetAnchorRotationalSkewScale();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -463,7 +463,7 @@ class SpriteOffsetAnchorFlip : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteOffsetAnchorFlip);
|
||||
SpriteOffsetAnchorFlip();
|
||||
~SpriteOffsetAnchorFlip();
|
||||
virtual ~SpriteOffsetAnchorFlip();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -473,7 +473,7 @@ class SpriteBatchNodeOffsetAnchorFlip : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteBatchNodeOffsetAnchorFlip);
|
||||
SpriteBatchNodeOffsetAnchorFlip();
|
||||
~SpriteBatchNodeOffsetAnchorFlip();
|
||||
virtual ~SpriteBatchNodeOffsetAnchorFlip();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -533,7 +533,7 @@ class SpriteChildrenVisibilityIssue665 : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteChildrenVisibilityIssue665);
|
||||
SpriteChildrenVisibilityIssue665();
|
||||
~SpriteChildrenVisibilityIssue665();
|
||||
virtual ~SpriteChildrenVisibilityIssue665();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -668,7 +668,7 @@ class SpriteBatchNodeSkewNegativeScaleChildren : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteBatchNodeSkewNegativeScaleChildren);
|
||||
SpriteBatchNodeSkewNegativeScaleChildren();
|
||||
~SpriteBatchNodeSkewNegativeScaleChildren();
|
||||
virtual ~SpriteBatchNodeSkewNegativeScaleChildren();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -678,7 +678,7 @@ class SpriteBatchNodeRotationalSkewNegativeScaleChildren : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteBatchNodeRotationalSkewNegativeScaleChildren);
|
||||
SpriteBatchNodeRotationalSkewNegativeScaleChildren();
|
||||
~SpriteBatchNodeRotationalSkewNegativeScaleChildren();
|
||||
virtual ~SpriteBatchNodeRotationalSkewNegativeScaleChildren();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -688,7 +688,7 @@ class SpriteSkewNegativeScaleChildren : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteSkewNegativeScaleChildren);
|
||||
SpriteSkewNegativeScaleChildren();
|
||||
~SpriteSkewNegativeScaleChildren();
|
||||
virtual ~SpriteSkewNegativeScaleChildren();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
@ -698,7 +698,7 @@ class SpriteRotationalSkewNegativeScaleChildren : public SpriteTestDemo
|
|||
public:
|
||||
CREATE_FUNC(SpriteRotationalSkewNegativeScaleChildren);
|
||||
SpriteRotationalSkewNegativeScaleChildren();
|
||||
~SpriteRotationalSkewNegativeScaleChildren();
|
||||
virtual ~SpriteRotationalSkewNegativeScaleChildren();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue