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:
|
2014-01-27 16:30:20 +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;
|
2015-03-15 02:33:15 +08:00
|
|
|
void backCallback(Ref* sender) override;
|
|
|
|
void nextCallback(Ref* sender) override;
|
|
|
|
void restartCallback(Ref* sender) override;
|
2013-09-13 16:38:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TouchableSpriteTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(TouchableSpriteTest);
|
2014-02-27 21:10:03 +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-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);
|
2014-02-27 21:10:03 +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-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);
|
2014-02-27 21:10:03 +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 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);
|
2014-01-06 18:26:14 +08:00
|
|
|
DirectorEventTest();
|
2013-12-21 16:56:28 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-22 02:55:16 +08:00
|
|
|
virtual void onExit() override;
|
|
|
|
|
|
|
|
virtual void update(float dt) override;
|
|
|
|
|
|
|
|
void onEvent1(EventCustom *event);
|
|
|
|
void onEvent2(EventCustom *event);
|
2013-12-21 16:56:28 +08:00
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
2013-12-22 02:55:16 +08:00
|
|
|
int _count1, _count2, _count3, _count4;
|
2013-12-21 16:56:28 +08:00
|
|
|
Label *_label1, *_label2, *_label3, *_label4;
|
2013-12-22 02:55:16 +08:00
|
|
|
EventListenerCustom *_event1, *_event2, *_event3, *_event4;
|
2013-12-21 16:56:28 +08:00
|
|
|
};
|
|
|
|
|
2014-01-21 10:23:05 +08:00
|
|
|
class GlobalZTouchTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(GlobalZTouchTest);
|
|
|
|
GlobalZTouchTest();
|
|
|
|
|
|
|
|
virtual void update(float dt) override;
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Sprite* _sprite;
|
|
|
|
float _accum;
|
|
|
|
};
|
|
|
|
|
2014-01-27 16:30:20 +08:00
|
|
|
class StopPropagationTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(StopPropagationTest);
|
|
|
|
StopPropagationTest();
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
2014-05-15 01:07:09 +08:00
|
|
|
bool isPointInNode(Vec2 pt, Node* node);
|
|
|
|
bool isPointInTopHalfAreaOfScreen(Vec2 pt);
|
2014-01-27 16:30:20 +08:00
|
|
|
};
|
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
class PauseResumeTargetTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(PauseResumeTargetTest);
|
|
|
|
PauseResumeTargetTest();
|
|
|
|
virtual ~PauseResumeTargetTest();
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
2014-02-28 15:46:48 +08:00
|
|
|
class Issue4129 : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Issue4129);
|
|
|
|
Issue4129();
|
|
|
|
virtual ~Issue4129();
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
EventListenerCustom* _customlistener;
|
|
|
|
bool _bugFixed;
|
|
|
|
};
|
|
|
|
|
2014-03-02 16:22:57 +08:00
|
|
|
class Issue4160 : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Issue4160);
|
|
|
|
Issue4160();
|
|
|
|
virtual ~Issue4160();
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
2014-02-28 15:46:48 +08:00
|
|
|
|
2014-03-28 07:38:06 +08:00
|
|
|
class DanglingNodePointersTest : public EventDispatcherTestDemo
|
2014-03-28 07:00:21 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-03-28 07:38:06 +08:00
|
|
|
CREATE_FUNC(DanglingNodePointersTest);
|
|
|
|
DanglingNodePointersTest();
|
|
|
|
virtual ~DanglingNodePointersTest();
|
2014-03-28 07:00:21 +08:00
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2014-04-08 07:46:03 +08:00
|
|
|
class RegisterAndUnregisterWhileEventHanldingTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(RegisterAndUnregisterWhileEventHanldingTest);
|
|
|
|
RegisterAndUnregisterWhileEventHanldingTest();
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2015-01-13 18:37:45 +08:00
|
|
|
class Issue9898 : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Issue9898);
|
|
|
|
Issue9898();
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
EventListenerCustom* _listener;
|
|
|
|
};
|
|
|
|
|
2013-09-13 16:38:21 +08:00
|
|
|
#endif /* defined(__samples__NewEventDispatcherTest__) */
|