2010-09-09 16:15:21 +08:00
|
|
|
#ifndef _SCHEDULER_TEST_H_
|
|
|
|
#define _SCHEDULER_TEST_H_
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
2012-07-20 14:05:52 +08:00
|
|
|
#include "cocos-ext.h"
|
2010-09-09 16:15:21 +08:00
|
|
|
#include "../testBasic.h"
|
2013-06-12 07:30:05 +08:00
|
|
|
#include "../BaseTest.h"
|
2010-09-09 16:15:21 +08:00
|
|
|
|
2012-07-19 17:22:36 +08:00
|
|
|
USING_NS_CC_EXT;
|
2010-09-09 16:15:21 +08:00
|
|
|
|
2013-06-12 07:30:05 +08:00
|
|
|
class SchedulerTestLayer : public BaseTest
|
2010-09-09 16:15:21 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void backCallback(Object* pSender);
|
|
|
|
void nextCallback(Object* pSender);
|
|
|
|
void restartCallback(Object* pSender);
|
2010-09-09 16:15:21 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// class SchedulerTestLayer : Layer
|
2010-09-09 16:15:21 +08:00
|
|
|
// {
|
|
|
|
// }
|
2013-06-20 14:17:10 +08:00
|
|
|
// -(String*) title;
|
|
|
|
// -(String*) subtitle;
|
2010-09-09 16:15:21 +08:00
|
|
|
//
|
|
|
|
// -(void) backCallback:(id) sender;
|
|
|
|
// -(void) nextCallback:(id) sender;
|
|
|
|
// -(void) restartCallback:(id) sender;
|
|
|
|
//
|
|
|
|
|
|
|
|
class SchedulerAutoremove : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void autoremove(float dt);
|
|
|
|
void tick(float dt);
|
2010-09-09 16:15:21 +08:00
|
|
|
private:
|
2012-06-08 13:55:28 +08:00
|
|
|
float accum;
|
2010-09-09 16:15:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SchedulerPauseResume : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void tick1(float dt);
|
|
|
|
void tick2(float dt);
|
|
|
|
void pause(float dt);
|
2010-09-09 16:15:21 +08:00
|
|
|
};
|
|
|
|
|
2012-06-12 18:12:45 +08:00
|
|
|
class SchedulerPauseResumeAll : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SchedulerPauseResumeAll();
|
|
|
|
virtual ~SchedulerPauseResumeAll();
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual void onExit();
|
2012-11-20 16:24:27 +08:00
|
|
|
virtual void update(float delta);
|
2012-06-12 18:12:45 +08:00
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
|
|
|
void tick1(float dt);
|
|
|
|
void tick2(float dt);
|
|
|
|
void pause(float dt);
|
|
|
|
void resume(float dt);
|
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
Set* _pausedTargets;
|
2012-06-12 18:12:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SchedulerPauseResumeAllUser : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SchedulerPauseResumeAllUser();
|
|
|
|
virtual ~SchedulerPauseResumeAllUser();
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual void onExit();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
|
|
|
void tick1(float dt);
|
|
|
|
void tick2(float dt);
|
|
|
|
void pause(float dt);
|
|
|
|
void resume(float dt);
|
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
Set* _pausedTargets;
|
2012-06-12 18:12:45 +08:00
|
|
|
};
|
|
|
|
|
2010-09-09 16:15:21 +08:00
|
|
|
class SchedulerUnscheduleAll : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void tick1(float dt);
|
|
|
|
void tick2(float dt);
|
|
|
|
void tick3(float dt);
|
|
|
|
void tick4(float dt);
|
|
|
|
void unscheduleAll(float dt);
|
2010-09-09 16:15:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SchedulerUnscheduleAllHard : public SchedulerTestLayer
|
|
|
|
{
|
2012-06-12 18:12:45 +08:00
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual void onExit();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
|
|
|
void tick1(float dt);
|
|
|
|
void tick2(float dt);
|
|
|
|
void tick3(float dt);
|
|
|
|
void tick4(float dt);
|
|
|
|
void unscheduleAll(float dt);
|
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _actionManagerActive;
|
2012-06-12 18:12:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SchedulerUnscheduleAllUserLevel : public SchedulerTestLayer
|
|
|
|
{
|
2010-09-09 16:15:21 +08:00
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void tick1(float dt);
|
|
|
|
void tick2(float dt);
|
|
|
|
void tick3(float dt);
|
|
|
|
void tick4(float dt);
|
|
|
|
void unscheduleAll(float dt);
|
2010-09-09 16:15:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SchedulerSchedulesAndRemove : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void tick1(float dt);
|
|
|
|
void tick2(float dt);
|
|
|
|
void tick3(float dt);
|
|
|
|
void tick4(float dt);
|
|
|
|
void scheduleAndUnschedule(float dt);
|
2010-09-09 16:15:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SchedulerUpdate : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void removeUpdates(float dt);
|
2010-09-09 16:15:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SchedulerUpdateAndCustom : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void update(float dt);
|
|
|
|
void tick(float dt);
|
|
|
|
void stopSelectors(float dt);
|
2010-09-09 16:15:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SchedulerUpdateFromCustom : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void update(float dt);
|
|
|
|
void schedUpdate(float dt);
|
|
|
|
void stopUpdate(float dt);
|
2010-09-09 16:15:21 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class TestNode : public Node
|
2010-09-09 16:15:21 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
~TestNode();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void initWithString(String* pStr, int priority);
|
2012-12-03 15:33:01 +08:00
|
|
|
virtual void update(float dt);
|
2010-09-09 16:15:21 +08:00
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
String* _pstring;
|
2010-09-09 16:15:21 +08:00
|
|
|
};
|
|
|
|
|
2010-09-25 14:19:15 +08:00
|
|
|
class RescheduleSelector : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void schedUpdate(float dt);
|
2010-09-25 14:19:15 +08:00
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
float _interval;
|
|
|
|
int _ticks;
|
2010-09-25 14:19:15 +08:00
|
|
|
};
|
|
|
|
|
2012-04-18 13:58:24 +08:00
|
|
|
class SchedulerDelayAndRepeat : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
2012-06-08 13:55:28 +08:00
|
|
|
void update(float dt);
|
2012-04-18 13:58:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SchedulerTimeScale : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void onEnter();
|
|
|
|
void onExit();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
2013-06-20 14:17:10 +08:00
|
|
|
ControlSlider* sliderCtl();
|
|
|
|
void sliderAction(Object* pSender, ControlEvent controlEvent);
|
|
|
|
ControlSlider* _sliderCtl;
|
2012-04-18 13:58:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TwoSchedulers : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~TwoSchedulers();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
void onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
ControlSlider* sliderCtl();
|
|
|
|
void sliderAction(Object* sender, ControlEvent controlEvent);
|
|
|
|
Scheduler *sched1;
|
|
|
|
Scheduler *sched2;
|
|
|
|
ActionManager *actionManager1;
|
|
|
|
ActionManager *actionManager2;
|
|
|
|
|
|
|
|
ControlSlider *sliderCtl1;
|
|
|
|
ControlSlider *sliderCtl2;
|
2012-04-18 13:58:24 +08:00
|
|
|
};
|
|
|
|
|
2013-03-29 21:48:35 +08:00
|
|
|
class SchedulerIssue2268 : public SchedulerTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~SchedulerIssue2268();
|
|
|
|
std::string title();
|
|
|
|
std::string subtitle();
|
|
|
|
void onEnter();
|
|
|
|
void update(float dt);
|
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
Node *testNode;
|
2013-03-29 21:48:35 +08:00
|
|
|
};
|
2012-04-18 13:58:24 +08:00
|
|
|
|
2010-09-09 16:15:21 +08:00
|
|
|
class SchedulerTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|