2013-09-12 16:01:14 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
2013-09-12 16:01:14 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2013-09-03 18:22:03 +08:00
|
|
|
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "base/CCEventListener.h"
|
2013-09-03 18:22:03 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2013-09-13 18:00:56 +08:00
|
|
|
EventListener::EventListener()
|
2013-09-03 18:22:03 +08:00
|
|
|
{}
|
|
|
|
|
|
|
|
EventListener::~EventListener()
|
|
|
|
{
|
2013-09-12 16:01:14 +08:00
|
|
|
CCLOGINFO("In the destructor of EventListener. %p", this);
|
2013-09-03 18:22:03 +08:00
|
|
|
}
|
|
|
|
|
2014-02-25 14:31:24 +08:00
|
|
|
bool EventListener::init(Type t, const ListenerID& listenerID, const std::function<void(Event*)>& callback)
|
2013-09-13 18:00:56 +08:00
|
|
|
{
|
2013-09-19 09:14:51 +08:00
|
|
|
_onEvent = callback;
|
|
|
|
_type = t;
|
2013-10-28 16:00:01 +08:00
|
|
|
_listenerID = listenerID;
|
2013-09-13 18:00:56 +08:00
|
|
|
_isRegistered = false;
|
2013-10-23 11:27:24 +08:00
|
|
|
_paused = true;
|
2014-04-03 15:32:16 +08:00
|
|
|
_isEnabled = true;
|
2013-09-13 18:00:56 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-12 11:25:28 +08:00
|
|
|
bool EventListener::checkAvailable()
|
2013-09-03 18:22:03 +08:00
|
|
|
{
|
2013-09-19 09:14:51 +08:00
|
|
|
return (_onEvent != nullptr);
|
2013-09-13 16:36:25 +08:00
|
|
|
}
|
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
NS_CC_END
|