From a2d9f2d7cfd00f3a06cd8dcef2d44c61b7d3a6f3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 18 Sep 2013 18:35:42 +0800 Subject: [PATCH] Make XXXEventListener as friend class of XXXEvent. Move the test of eventdispatchertest. --- cocos2dx/event_dispatcher/CCAccelerationEvent.h | 1 + cocos2dx/event_dispatcher/CCAccelerationEventListener.cpp | 2 +- cocos2dx/event_dispatcher/CCKeyboardEvent.h | 2 ++ samples/Cpp/TestCpp/Classes/controller.cpp | 3 +-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cocos2dx/event_dispatcher/CCAccelerationEvent.h b/cocos2dx/event_dispatcher/CCAccelerationEvent.h index 75168ce4b3..b72f7ac808 100644 --- a/cocos2dx/event_dispatcher/CCAccelerationEvent.h +++ b/cocos2dx/event_dispatcher/CCAccelerationEvent.h @@ -39,6 +39,7 @@ public: private: Acceleration _acc; + friend class AccelerationEventListener; }; NS_CC_END diff --git a/cocos2dx/event_dispatcher/CCAccelerationEventListener.cpp b/cocos2dx/event_dispatcher/CCAccelerationEventListener.cpp index 8b2d9dbf9c..7fa8d6d9a5 100644 --- a/cocos2dx/event_dispatcher/CCAccelerationEventListener.cpp +++ b/cocos2dx/event_dispatcher/CCAccelerationEventListener.cpp @@ -56,7 +56,7 @@ bool AccelerationEventListener::init(std::function(event); - this->onAccelerationEvent(&accEvent->acc, event); + this->onAccelerationEvent(&accEvent->_acc, event); }; if (EventListener::init(AccelerationEvent::EVENT_TYPE, listener)) diff --git a/cocos2dx/event_dispatcher/CCKeyboardEvent.h b/cocos2dx/event_dispatcher/CCKeyboardEvent.h index 5af871f68f..f7407fbbf8 100644 --- a/cocos2dx/event_dispatcher/CCKeyboardEvent.h +++ b/cocos2dx/event_dispatcher/CCKeyboardEvent.h @@ -207,6 +207,8 @@ public: private: KeyCode _keyCode; bool _isPressed; + + friend class KeyboardEventListener; }; NS_CC_END diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp index af088f5af6..7717917111 100644 --- a/samples/Cpp/TestCpp/Classes/controller.cpp +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -14,8 +14,6 @@ struct { const char *test_name; std::function callback; } g_aTestNames[] = { - - { "NewEventDispatcherTest", []() { return new EventDispatcherTestScene(); } }, { "Accelerometer", []() { return new AccelerometerTestScene(); } }, { "ActionManagerTest", [](){return new ActionManagerTestScene(); } }, { "ActionsEaseTest", [](){return new ActionsEaseTestScene();} }, @@ -44,6 +42,7 @@ struct { #endif { "CurrentLanguageTest", []() { return new CurrentLanguageTestScene(); } }, { "DrawPrimitivesTest", [](){return new DrawPrimitivesTestScene();} }, + { "EventDispatcherTest", []() { return new EventDispatcherTestScene(); } }, { "EffectAdvancedTest", []() { return new EffectAdvanceScene(); } }, { "EffectsTest", [](){return new EffectTestScene();} }, { "ExtensionsTest", []() { return new ExtensionsTestScene(); } },