axmol/samples/test-cpp/Classes/SchedulerTest/SchedulerTest.h

310 lines
6.9 KiB
C
Raw Normal View History

2010-09-09 16:15:21 +08:00
#ifndef _SCHEDULER_TEST_H_
#define _SCHEDULER_TEST_H_
#include "cocos2d.h"
#include "extensions/cocos-ext.h"
2010-09-09 16:15:21 +08:00
#include "../testBasic.h"
#include "../BaseTest.h"
2010-09-09 16:15:21 +08:00
USING_NS_CC_EXT;
2010-09-09 16:15:21 +08:00
class SchedulerTestLayer : public BaseTest
2010-09-09 16:15:21 +08:00
{
public:
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-09 16:15:21 +08:00
void backCallback(Object* sender);
void nextCallback(Object* sender);
void restartCallback(Object* sender);
2010-09-09 16:15:21 +08:00
};
// class SchedulerTestLayer : Layer
2010-09-09 16:15:21 +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:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerAutoremove);
2010-09-09 16:15:21 +08:00
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-09 16:15:21 +08:00
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:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerPauseResume);
2010-09-09 16:15:21 +08:00
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-09 16:15:21 +08:00
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:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerPauseResumeAll);
2012-06-12 18:12:45 +08:00
SchedulerPauseResumeAll();
virtual ~SchedulerPauseResumeAll();
virtual void onEnter();
virtual void onExit();
2012-11-20 16:24:27 +08:00
virtual void update(float delta);
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-06-12 18:12:45 +08:00
void tick1(float dt);
void tick2(float dt);
void pause(float dt);
void resume(float dt);
private:
2013-12-07 14:28:37 +08:00
Vector<Object*> _pausedTargets;
2012-06-12 18:12:45 +08:00
};
class SchedulerPauseResumeAllUser : public SchedulerTestLayer
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerPauseResumeAllUser);
2012-06-12 18:12:45 +08:00
SchedulerPauseResumeAllUser();
virtual ~SchedulerPauseResumeAllUser();
virtual void onEnter();
virtual void onExit();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-06-12 18:12:45 +08:00
void tick1(float dt);
void tick2(float dt);
void pause(float dt);
void resume(float dt);
private:
2013-12-07 14:28:37 +08:00
Vector<Object*> _pausedTargets;
2012-06-12 18:12:45 +08:00
};
2010-09-09 16:15:21 +08:00
class SchedulerUnscheduleAll : public SchedulerTestLayer
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerUnscheduleAll);
2010-09-09 16:15:21 +08:00
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-09 16:15:21 +08:00
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:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerUnscheduleAllHard);
2012-06-12 18:12:45 +08:00
virtual void onEnter();
virtual void onExit();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-06-12 18:12:45 +08:00
void tick1(float dt);
void tick2(float dt);
void tick3(float dt);
void tick4(float dt);
void unscheduleAll(float dt);
private:
bool _actionManagerActive;
2012-06-12 18:12:45 +08:00
};
class SchedulerUnscheduleAllUserLevel : public SchedulerTestLayer
{
2010-09-09 16:15:21 +08:00
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerUnscheduleAllUserLevel);
2010-09-09 16:15:21 +08:00
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-09 16:15:21 +08:00
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:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerSchedulesAndRemove);
2010-09-09 16:15:21 +08:00
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-09 16:15:21 +08:00
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:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerUpdate);
2010-09-09 16:15:21 +08:00
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-09 16:15:21 +08:00
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:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerUpdateAndCustom);
2010-09-09 16:15:21 +08:00
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-09 16:15:21 +08:00
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:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerUpdateFromCustom);
2010-09-09 16:15:21 +08:00
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-09 16:15:21 +08:00
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
};
class TestNode : public Node
2010-09-09 16:15:21 +08:00
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(TestNode);
2010-09-09 16:15:21 +08:00
~TestNode();
2013-12-18 16:03:07 +08:00
void initWithString(const std::string& str, int priority);
virtual void update(float dt);
2010-09-09 16:15:21 +08:00
private:
2013-12-18 16:03:07 +08:00
std::string _string;
2010-09-09 16:15:21 +08:00
};
class RescheduleSelector : public SchedulerTestLayer
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(RescheduleSelector);
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-06-08 13:55:28 +08:00
void schedUpdate(float dt);
private:
float _interval;
int _ticks;
};
class SchedulerDelayAndRepeat : public SchedulerTestLayer
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerDelayAndRepeat);
virtual void onEnter();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-06-08 13:55:28 +08:00
void update(float dt);
};
class SchedulerTimeScale : public SchedulerTestLayer
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerTimeScale);
void onEnter();
void onExit();
virtual std::string title() const override;
virtual std::string subtitle() const override;
ControlSlider* sliderCtl();
2013-07-26 15:22:45 +08:00
void sliderAction(Object* sender, Control::EventType controlEvent);
ControlSlider* _sliderCtl;
};
class TwoSchedulers : public SchedulerTestLayer
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(TwoSchedulers);
virtual ~TwoSchedulers();
virtual std::string title() const override;
virtual std::string subtitle() const override;
void onEnter();
ControlSlider* sliderCtl();
void sliderAction(Object* sender, Control::EventType controlEvent);
Scheduler *sched1;
Scheduler *sched2;
ActionManager *actionManager1;
ActionManager *actionManager2;
ControlSlider *sliderCtl1;
ControlSlider *sliderCtl2;
};
class SchedulerIssue2268 : public SchedulerTestLayer
{
2013-11-14 07:55:36 +08:00
public:
CREATE_FUNC(SchedulerIssue2268);
~SchedulerIssue2268();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2013-11-14 07:55:36 +08:00
void onEnter();
void update(float dt);
private:
Node *testNode;
};
2010-09-09 16:15:21 +08:00
class SchedulerTestScene : public TestScene
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(SchedulerTestScene);
2010-09-09 16:15:21 +08:00
virtual void runThisTest();
};
#endif