2013-09-13 16:38:21 +08:00
|
|
|
//
|
|
|
|
// NewEventDispatcherTest.h
|
|
|
|
// samples
|
|
|
|
//
|
|
|
|
// Created by James Chen on 9/13/13.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef __samples__NewEventDispatcherTest__
|
|
|
|
#define __samples__NewEventDispatcherTest__
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "../testBasic.h"
|
|
|
|
#include "../BaseTest.h"
|
|
|
|
|
|
|
|
class EventDispatcherTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
class EventDispatcherTestDemo : public BaseTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-13 16:38:21 +08:00
|
|
|
void backCallback(Object* sender);
|
|
|
|
void nextCallback(Object* sender);
|
|
|
|
void restartCallback(Object* sender);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TouchableSpriteTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(TouchableSpriteTest);
|
2013-09-13 16:38:21 +08:00
|
|
|
virtual void onEnter();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-13 16:38:21 +08:00
|
|
|
};
|
|
|
|
|
2013-09-16 16:02:48 +08:00
|
|
|
class FixedPriorityTest : public EventDispatcherTestDemo
|
2013-09-16 15:43:48 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(FixedPriorityTest);
|
2013-09-16 15:43:48 +08:00
|
|
|
virtual void onEnter();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-16 15:43:48 +08:00
|
|
|
};
|
|
|
|
|
2013-09-18 22:23:02 +08:00
|
|
|
class RemoveListenerWhenDispatching : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RemoveListenerWhenDispatching);
|
2013-09-18 22:23:02 +08:00
|
|
|
virtual void onEnter();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-18 22:23:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class CustomEventTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(CustomEventTest);
|
2013-09-18 22:23:02 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-18 22:23:02 +08:00
|
|
|
private:
|
2013-09-20 19:19:31 +08:00
|
|
|
EventListenerCustom* _listener;
|
2013-10-28 10:49:43 +08:00
|
|
|
EventListenerCustom* _listener2;
|
2013-09-18 22:23:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class LabelKeyboardEventTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(LabelKeyboardEventTest);
|
2013-09-18 22:23:02 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-18 22:23:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SpriteAccelerationEventTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(SpriteAccelerationEventTest);
|
2013-09-18 22:23:02 +08:00
|
|
|
virtual void onEnter() override;
|
2013-09-18 22:45:48 +08:00
|
|
|
virtual void onExit() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-18 22:23:02 +08:00
|
|
|
};
|
2013-09-16 15:43:48 +08:00
|
|
|
|
2013-10-23 16:14:03 +08:00
|
|
|
class RemoveAndRetainNodeTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RemoveAndRetainNodeTest);
|
2013-10-23 16:14:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-10-23 16:14:03 +08:00
|
|
|
private:
|
|
|
|
Sprite* _sprite;
|
|
|
|
bool _spriteSaved;
|
|
|
|
};
|
|
|
|
|
2013-11-02 21:47:00 +08:00
|
|
|
class RemoveListenerAfterAddingTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RemoveListenerAfterAddingTest);
|
2013-11-02 21:47:00 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-11-02 21:47:00 +08:00
|
|
|
};
|
|
|
|
|
2013-12-21 16:56:28 +08:00
|
|
|
class DirectorEventTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(DirectorEventTest);
|
|
|
|
virtual void onEnter() override;
|
|
|
|
void onEvent1(EventListener *event);
|
|
|
|
void onEvent2(EventListener *event);
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Label *_label1, *_label2, *_label3, *_label4;
|
|
|
|
};
|
|
|
|
|
2013-09-13 16:38:21 +08:00
|
|
|
#endif /* defined(__samples__NewEventDispatcherTest__) */
|