mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3132 from samuele3hu/ScriptHandler
issue 2377:Add scriptHandlerMgr to manager lua script handler
This commit is contained in:
commit
80590dcfc1
|
@ -1 +1 @@
|
||||||
08ecad70e8370c7af451fddea1c59d05e80ca696
|
1ab0fd6fdad74af8ce054c089d8571a05a7a04d8
|
|
@ -87,7 +87,6 @@ Node::Node(void)
|
||||||
, _ignoreAnchorPointForPosition(false)
|
, _ignoreAnchorPointForPosition(false)
|
||||||
, _reorderChildDirty(false)
|
, _reorderChildDirty(false)
|
||||||
, _isTransitionFinished(false)
|
, _isTransitionFinished(false)
|
||||||
, _scriptHandler(0)
|
|
||||||
, _updateScriptHandler(0)
|
, _updateScriptHandler(0)
|
||||||
, _componentContainer(NULL)
|
, _componentContainer(NULL)
|
||||||
{
|
{
|
||||||
|
@ -107,7 +106,6 @@ Node::~Node(void)
|
||||||
{
|
{
|
||||||
CCLOGINFO( "cocos2d: deallocing: %p", this );
|
CCLOGINFO( "cocos2d: deallocing: %p", this );
|
||||||
|
|
||||||
unregisterScriptHandler();
|
|
||||||
if (_updateScriptHandler)
|
if (_updateScriptHandler)
|
||||||
{
|
{
|
||||||
ScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(_updateScriptHandler);
|
ScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(_updateScriptHandler);
|
||||||
|
@ -987,23 +985,6 @@ void Node::onExit()
|
||||||
arrayMakeObjectsPerformSelector(_children, onExit, Node*);
|
arrayMakeObjectsPerformSelector(_children, onExit, Node*);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::registerScriptHandler(int nHandler)
|
|
||||||
{
|
|
||||||
unregisterScriptHandler();
|
|
||||||
_scriptHandler = nHandler;
|
|
||||||
LUALOG("[LUA] Add Node event handler: %d", _scriptHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Node::unregisterScriptHandler(void)
|
|
||||||
{
|
|
||||||
if (_scriptHandler)
|
|
||||||
{
|
|
||||||
ScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(_scriptHandler);
|
|
||||||
LUALOG("[LUA] Remove Node event handler: %d", _scriptHandler);
|
|
||||||
_scriptHandler = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Node::setActionManager(ActionManager* actionManager)
|
void Node::setActionManager(ActionManager* actionManager)
|
||||||
{
|
{
|
||||||
if( actionManager != _actionManager ) {
|
if( actionManager != _actionManager ) {
|
||||||
|
|
|
@ -857,47 +857,6 @@ public:
|
||||||
* @return Whether or not the node is running.
|
* @return Whether or not the node is running.
|
||||||
*/
|
*/
|
||||||
virtual bool isRunning() const;
|
virtual bool isRunning() const;
|
||||||
|
|
||||||
|
|
||||||
/// @{
|
|
||||||
/// @name Script Bindings for lua
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a script function that will be called in onEnter() & onExit() seires functions.
|
|
||||||
*
|
|
||||||
* This handler will be removed automatically after onExit() called.
|
|
||||||
* @code
|
|
||||||
* -- lua sample
|
|
||||||
* local function sceneEventHandler(eventType)
|
|
||||||
* if eventType == kNodeOnEnter then
|
|
||||||
* -- do something
|
|
||||||
* elseif evetType == kNodeOnExit then
|
|
||||||
* -- do something
|
|
||||||
* end
|
|
||||||
* end
|
|
||||||
* scene::registerScriptHandler(sceneEventHandler)
|
|
||||||
* @endcode
|
|
||||||
*
|
|
||||||
* @warning This method is for internal usage, don't call it manually.
|
|
||||||
* @todo Perhaps we should rename it to get/set/removeScriptHandler acoording to the function name style.
|
|
||||||
*
|
|
||||||
* @param handler A number that indicates a lua function.
|
|
||||||
*/
|
|
||||||
virtual void registerScriptHandler(int handler);
|
|
||||||
/**
|
|
||||||
* Unregisters a script function that will be called in onEnter() & onExit() series functions.
|
|
||||||
*
|
|
||||||
* @see registerScriptHandler(int)
|
|
||||||
*/
|
|
||||||
virtual void unregisterScriptHandler(void);
|
|
||||||
/**
|
|
||||||
* Gets script handler for onEnter/onExit event.
|
|
||||||
* This is an internal method. g
|
|
||||||
* @see registerScriptHandler(int)
|
|
||||||
*
|
|
||||||
* @return A number that indicates a lua function.
|
|
||||||
*/
|
|
||||||
inline int getScriptHandler() const { return _scriptHandler; };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules for lua script.
|
* Schedules for lua script.
|
||||||
|
|
|
@ -47,9 +47,6 @@ Layer::Layer()
|
||||||
, _accelerometerEnabled(false)
|
, _accelerometerEnabled(false)
|
||||||
, _keyboardEnabled(false)
|
, _keyboardEnabled(false)
|
||||||
, _keypadEnabled(false)
|
, _keypadEnabled(false)
|
||||||
, _scriptTouchHandlerEntry(NULL)
|
|
||||||
, _scriptKeypadHandlerEntry(NULL)
|
|
||||||
, _scriptAccelerateHandlerEntry(NULL)
|
|
||||||
, _touchPriority(0)
|
, _touchPriority(0)
|
||||||
, _touchMode(kTouchesAllAtOnce)
|
, _touchMode(kTouchesAllAtOnce)
|
||||||
{
|
{
|
||||||
|
@ -59,9 +56,7 @@ Layer::Layer()
|
||||||
|
|
||||||
Layer::~Layer()
|
Layer::~Layer()
|
||||||
{
|
{
|
||||||
unregisterScriptTouchHandler();
|
|
||||||
unregisterScriptKeypadHandler();
|
|
||||||
unregisterScriptAccelerateHandler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Layer::init()
|
bool Layer::init()
|
||||||
|
@ -101,51 +96,20 @@ void Layer::registerWithTouchDispatcher()
|
||||||
{
|
{
|
||||||
TouchDispatcher* pDispatcher = Director::getInstance()->getTouchDispatcher();
|
TouchDispatcher* pDispatcher = Director::getInstance()->getTouchDispatcher();
|
||||||
|
|
||||||
// Using LuaBindings
|
if( _touchMode == kTouchesAllAtOnce ) {
|
||||||
if (_scriptTouchHandlerEntry)
|
pDispatcher->addStandardDelegate(this, 0);
|
||||||
{
|
} else {
|
||||||
if (_scriptTouchHandlerEntry->isMultiTouches())
|
pDispatcher->addTargetedDelegate(this, _touchPriority, true);
|
||||||
{
|
|
||||||
pDispatcher->addStandardDelegate(this, 0);
|
|
||||||
LUALOG("[LUA] Add multi-touches event handler: %d", _scriptTouchHandlerEntry->getHandler());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pDispatcher->addTargetedDelegate(this,
|
|
||||||
_scriptTouchHandlerEntry->getPriority(),
|
|
||||||
_scriptTouchHandlerEntry->getSwallowsTouches());
|
|
||||||
LUALOG("[LUA] Add touch event handler: %d", _scriptTouchHandlerEntry->getHandler());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( _touchMode == kTouchesAllAtOnce ) {
|
|
||||||
pDispatcher->addStandardDelegate(this, 0);
|
|
||||||
} else {
|
|
||||||
pDispatcher->addTargetedDelegate(this, _touchPriority, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::registerScriptTouchHandler(int nHandler, bool bIsMultiTouches, int nPriority, bool bSwallowsTouches)
|
|
||||||
{
|
|
||||||
unregisterScriptTouchHandler();
|
|
||||||
_scriptTouchHandlerEntry = TouchScriptHandlerEntry::create(nHandler, bIsMultiTouches, nPriority, bSwallowsTouches);
|
|
||||||
_scriptTouchHandlerEntry->retain();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layer::unregisterScriptTouchHandler(void)
|
|
||||||
{
|
|
||||||
CC_SAFE_RELEASE_NULL(_scriptTouchHandlerEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Layer::excuteScriptTouchHandler(int nEventType, Touch *pTouch)
|
int Layer::excuteScriptTouchHandler(int nEventType, Touch *pTouch)
|
||||||
{
|
{
|
||||||
if (kScriptTypeLua == _scriptType)
|
if (kScriptTypeLua == _scriptType)
|
||||||
{
|
{
|
||||||
Set touches;
|
Set touches;
|
||||||
touches.addObject((Object*)pTouch);
|
touches.addObject((Object*)pTouch);
|
||||||
TouchesScriptData data(nEventType,kLayerTouches,(void*)this,&touches);
|
TouchesScriptData data(nEventType,(void*)this,&touches);
|
||||||
ScriptEvent event(kTouchesEvent,&data);
|
ScriptEvent event(kTouchesEvent,&data);
|
||||||
return ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
return ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
||||||
}
|
}
|
||||||
|
@ -161,7 +125,7 @@ int Layer::excuteScriptTouchHandler(int nEventType, Set *pTouches)
|
||||||
{
|
{
|
||||||
if (kScriptTypeLua == _scriptType)
|
if (kScriptTypeLua == _scriptType)
|
||||||
{
|
{
|
||||||
TouchesScriptData data(nEventType,kLayerTouches,(void*)this,pTouches);
|
TouchesScriptData data(nEventType,(void*)this,pTouches);
|
||||||
ScriptEvent event(kTouchesEvent,&data);
|
ScriptEvent event(kTouchesEvent,&data);
|
||||||
return ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
return ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
||||||
}
|
}
|
||||||
|
@ -291,18 +255,6 @@ void Layer::didAccelerate(Acceleration* pAccelerationValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::registerScriptAccelerateHandler(int nHandler)
|
|
||||||
{
|
|
||||||
unregisterScriptAccelerateHandler();
|
|
||||||
_scriptAccelerateHandlerEntry = ScriptHandlerEntry::create(nHandler);
|
|
||||||
_scriptAccelerateHandlerEntry->retain();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layer::unregisterScriptAccelerateHandler(void)
|
|
||||||
{
|
|
||||||
CC_SAFE_RELEASE_NULL(_scriptAccelerateHandlerEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// isKeyboardEnabled getter
|
/// isKeyboardEnabled getter
|
||||||
bool Layer::isKeyboardEnabled() const
|
bool Layer::isKeyboardEnabled() const
|
||||||
{
|
{
|
||||||
|
@ -356,23 +308,11 @@ void Layer::setKeypadEnabled(bool enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::registerScriptKeypadHandler(int nHandler)
|
|
||||||
{
|
|
||||||
unregisterScriptKeypadHandler();
|
|
||||||
_scriptKeypadHandlerEntry = ScriptHandlerEntry::create(nHandler);
|
|
||||||
_scriptKeypadHandlerEntry->retain();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layer::unregisterScriptKeypadHandler(void)
|
|
||||||
{
|
|
||||||
CC_SAFE_RELEASE_NULL(_scriptKeypadHandlerEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layer::keyBackClicked(void)
|
void Layer::keyBackClicked(void)
|
||||||
{
|
{
|
||||||
if (NULL != _scriptKeypadHandlerEntry && 0 != _scriptKeypadHandlerEntry->getHandler())
|
if (kScriptTypeLua == _scriptType)
|
||||||
{
|
{
|
||||||
KeypadScriptData data(kTypeBackClicked,kLayerKeypad,(void*)this);
|
KeypadScriptData data(kTypeBackClicked,(void*)this);
|
||||||
ScriptEvent event(kKeypadEvent,(void*)&data);
|
ScriptEvent event(kKeypadEvent,(void*)&data);
|
||||||
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
||||||
}
|
}
|
||||||
|
@ -384,9 +324,9 @@ void Layer::keyBackClicked(void)
|
||||||
|
|
||||||
void Layer::keyMenuClicked(void)
|
void Layer::keyMenuClicked(void)
|
||||||
{
|
{
|
||||||
if (NULL != _scriptKeypadHandlerEntry && 0 != _scriptKeypadHandlerEntry->getHandler())
|
if (kScriptTypeLua == _scriptType)
|
||||||
{
|
{
|
||||||
KeypadScriptData data(kTypeMenuClicked,kLayerKeypad,(void*)this);
|
KeypadScriptData data(kTypeMenuClicked,(void*)this);
|
||||||
ScriptEvent event(kKeypadEvent,(void*)&data);
|
ScriptEvent event(kKeypadEvent,(void*)&data);
|
||||||
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
||||||
}
|
}
|
||||||
|
@ -425,8 +365,6 @@ void Layer::onExit()
|
||||||
if( _touchEnabled )
|
if( _touchEnabled )
|
||||||
{
|
{
|
||||||
pDirector->getTouchDispatcher()->removeDelegate(this);
|
pDirector->getTouchDispatcher()->removeDelegate(this);
|
||||||
// [lua]:don't unregister script touch handler, or the handler will be destroyed
|
|
||||||
// unregisterScriptTouchHandler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove this layer from the delegates who concern Accelerometer Sensor
|
// remove this layer from the delegates who concern Accelerometer Sensor
|
||||||
|
|
|
@ -83,8 +83,6 @@ public:
|
||||||
virtual void ccTouchesCancelled(Set *pTouches, Event *pEvent);
|
virtual void ccTouchesCancelled(Set *pTouches, Event *pEvent);
|
||||||
|
|
||||||
virtual void didAccelerate(Acceleration* pAccelerationValue);
|
virtual void didAccelerate(Acceleration* pAccelerationValue);
|
||||||
void registerScriptAccelerateHandler(int nHandler);
|
|
||||||
void unregisterScriptAccelerateHandler(void);
|
|
||||||
|
|
||||||
/** If isTouchEnabled, this method is called onEnter. Override it to change the
|
/** If isTouchEnabled, this method is called onEnter. Override it to change the
|
||||||
way Layer receives touch events.
|
way Layer receives touch events.
|
||||||
|
@ -97,11 +95,6 @@ public:
|
||||||
@since v0.8.0
|
@since v0.8.0
|
||||||
*/
|
*/
|
||||||
virtual void registerWithTouchDispatcher(void);
|
virtual void registerWithTouchDispatcher(void);
|
||||||
|
|
||||||
/** Register script touch events handler */
|
|
||||||
virtual void registerScriptTouchHandler(int nHandler, bool bIsMultiTouches = false, int nPriority = INT_MIN, bool bSwallowsTouches = false);
|
|
||||||
/** Unregister script touch events handler */
|
|
||||||
virtual void unregisterScriptTouchHandler(void);
|
|
||||||
|
|
||||||
/** whether or not it will receive Touch events.
|
/** whether or not it will receive Touch events.
|
||||||
You can enable / disable touch events with this property.
|
You can enable / disable touch events with this property.
|
||||||
|
@ -139,18 +132,8 @@ public:
|
||||||
virtual bool isKeypadEnabled() const;
|
virtual bool isKeypadEnabled() const;
|
||||||
virtual void setKeypadEnabled(bool value);
|
virtual void setKeypadEnabled(bool value);
|
||||||
|
|
||||||
/** Register keypad events handler */
|
|
||||||
void registerScriptKeypadHandler(int nHandler);
|
|
||||||
/** Unregister keypad events handler */
|
|
||||||
void unregisterScriptKeypadHandler(void);
|
|
||||||
|
|
||||||
virtual void keyBackClicked(void);
|
virtual void keyBackClicked(void);
|
||||||
virtual void keyMenuClicked(void);
|
virtual void keyMenuClicked(void);
|
||||||
|
|
||||||
inline TouchScriptHandlerEntry* getScriptTouchHandlerEntry() const { return _scriptTouchHandlerEntry; };
|
|
||||||
inline ScriptHandlerEntry* getScriptKeypadHandlerEntry() const { return _scriptKeypadHandlerEntry; };
|
|
||||||
inline ScriptHandlerEntry* getScriptAccelerateHandlerEntry() const { return _scriptAccelerateHandlerEntry; };
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Overrides
|
// Overrides
|
||||||
//
|
//
|
||||||
|
@ -165,11 +148,6 @@ protected:
|
||||||
bool _keypadEnabled;
|
bool _keypadEnabled;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Script touch events handler
|
|
||||||
TouchScriptHandlerEntry* _scriptTouchHandlerEntry;
|
|
||||||
ScriptHandlerEntry* _scriptKeypadHandlerEntry;
|
|
||||||
ScriptHandlerEntry* _scriptAccelerateHandlerEntry;
|
|
||||||
|
|
||||||
int _touchPriority;
|
int _touchPriority;
|
||||||
ccTouchesMode _touchMode;
|
ccTouchesMode _touchMode;
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,6 @@ bool MenuItem::initWithCallback(const ccMenuCallback& callback)
|
||||||
MenuItem::~MenuItem()
|
MenuItem::~MenuItem()
|
||||||
{
|
{
|
||||||
CC_SAFE_RELEASE(_target);
|
CC_SAFE_RELEASE(_target);
|
||||||
|
|
||||||
unregisterScriptTapHandler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuItem::selected()
|
void MenuItem::selected()
|
||||||
|
@ -105,23 +103,6 @@ void MenuItem::unselected()
|
||||||
_selected = false;
|
_selected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuItem::registerScriptTapHandler(int nHandler)
|
|
||||||
{
|
|
||||||
unregisterScriptTapHandler();
|
|
||||||
_scriptTapHandler = nHandler;
|
|
||||||
LUALOG("[LUA] Add MenuItem script handler: %d", _scriptTapHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuItem::unregisterScriptTapHandler(void)
|
|
||||||
{
|
|
||||||
if (_scriptTapHandler)
|
|
||||||
{
|
|
||||||
ScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(_scriptTapHandler);
|
|
||||||
LUALOG("[LUA] Remove MenuItem script handler: %d", _scriptTapHandler);
|
|
||||||
_scriptTapHandler = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuItem::activate()
|
void MenuItem::activate()
|
||||||
{
|
{
|
||||||
if (_enabled)
|
if (_enabled)
|
||||||
|
|
|
@ -62,7 +62,6 @@ public:
|
||||||
MenuItem()
|
MenuItem()
|
||||||
: _selected(false)
|
: _selected(false)
|
||||||
, _enabled(false)
|
, _enabled(false)
|
||||||
, _scriptTapHandler(0)
|
|
||||||
, _callback(nullptr)
|
, _callback(nullptr)
|
||||||
, _target(NULL)
|
, _target(NULL)
|
||||||
{}
|
{}
|
||||||
|
@ -86,11 +85,6 @@ public:
|
||||||
virtual void selected();
|
virtual void selected();
|
||||||
/** The item was unselected */
|
/** The item was unselected */
|
||||||
virtual void unselected();
|
virtual void unselected();
|
||||||
|
|
||||||
/** Register menu handler script function */
|
|
||||||
virtual void registerScriptTapHandler(int nHandler);
|
|
||||||
virtual void unregisterScriptTapHandler(void);
|
|
||||||
int getScriptTapHandler() const { return _scriptTapHandler; };
|
|
||||||
|
|
||||||
virtual bool isEnabled() const;
|
virtual bool isEnabled() const;
|
||||||
//@note: It's 'setIsEnable' in cocos2d-iphone.
|
//@note: It's 'setIsEnable' in cocos2d-iphone.
|
||||||
|
@ -105,7 +99,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
bool _selected;
|
bool _selected;
|
||||||
bool _enabled;
|
bool _enabled;
|
||||||
int _scriptTapHandler;
|
|
||||||
// callback
|
// callback
|
||||||
ccMenuCallback _callback;
|
ccMenuCallback _callback;
|
||||||
// If using the old API, the _target needs to be retained / released
|
// If using the old API, the _target needs to be retained / released
|
||||||
|
|
|
@ -166,19 +166,10 @@ enum ScriptEventType
|
||||||
kTouchesEvent,
|
kTouchesEvent,
|
||||||
kKeypadEvent,
|
kKeypadEvent,
|
||||||
kAccelerometerEvent,
|
kAccelerometerEvent,
|
||||||
|
kControlEvent,
|
||||||
kCommonEvent,
|
kCommonEvent,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TouchesObjectType
|
|
||||||
{
|
|
||||||
kLayerTouches = 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum KeypadObjectType
|
|
||||||
{
|
|
||||||
kLayerKeypad = 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BasicScriptData
|
struct BasicScriptData
|
||||||
{
|
{
|
||||||
//nativeobject:to get handler for lua or to get jsobject for js
|
//nativeobject:to get handler for lua or to get jsobject for js
|
||||||
|
@ -209,12 +200,10 @@ struct SchedulerScriptData
|
||||||
struct TouchesScriptData
|
struct TouchesScriptData
|
||||||
{
|
{
|
||||||
int actionType;
|
int actionType;
|
||||||
int objectType;
|
|
||||||
void* nativeObject;
|
void* nativeObject;
|
||||||
Set* touches;
|
Set* touches;
|
||||||
TouchesScriptData(int inActionType,int inObjectType,void* inNativeObject,Set* inTouches)
|
TouchesScriptData(int inActionType,void* inNativeObject,Set* inTouches)
|
||||||
:actionType(inActionType),
|
:actionType(inActionType),
|
||||||
objectType(inObjectType),
|
|
||||||
nativeObject(inNativeObject),
|
nativeObject(inNativeObject),
|
||||||
touches(inTouches)
|
touches(inTouches)
|
||||||
{
|
{
|
||||||
|
@ -224,10 +213,9 @@ struct TouchesScriptData
|
||||||
struct KeypadScriptData
|
struct KeypadScriptData
|
||||||
{
|
{
|
||||||
int actionType;
|
int actionType;
|
||||||
int objectType;
|
|
||||||
void* nativeObject;
|
void* nativeObject;
|
||||||
KeypadScriptData(int inActionType,int inObjectType,void* inNativeObject)
|
KeypadScriptData(int inActionType,void* inNativeObject)
|
||||||
:actionType(inActionType),objectType(inObjectType),nativeObject(inNativeObject)
|
:actionType(inActionType),nativeObject(inNativeObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -285,7 +273,7 @@ public:
|
||||||
virtual void removeScriptHandler(int nHandler) {};
|
virtual void removeScriptHandler(int nHandler) {};
|
||||||
|
|
||||||
/** Reallocate script function handler, only LuaEngine class need to implement this function. */
|
/** Reallocate script function handler, only LuaEngine class need to implement this function. */
|
||||||
virtual int reallocateScriptHandler(int nHandler) { return -1;}
|
virtual int reallocateScriptHandler(int nHandler) { return 0;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Execute script code contained in the given string.
|
@brief Execute script code contained in the given string.
|
||||||
|
|
|
@ -30,8 +30,10 @@ THE SOFTWARE.
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class ScriptHandlerMgr;
|
||||||
class CC_DLL NotificationCenter : public Object
|
class CC_DLL NotificationCenter : public Object
|
||||||
{
|
{
|
||||||
|
friend class ScriptHandlerMgr;
|
||||||
public:
|
public:
|
||||||
/** NotificationCenter constructor */
|
/** NotificationCenter constructor */
|
||||||
NotificationCenter();
|
NotificationCenter();
|
||||||
|
|
|
@ -78,8 +78,6 @@ bool Control::init()
|
||||||
this->setTouchPriority(1);
|
this->setTouchPriority(1);
|
||||||
// Initialise the tables
|
// Initialise the tables
|
||||||
_dispatchTable = new Dictionary();
|
_dispatchTable = new Dictionary();
|
||||||
// Initialise the mapHandleOfControlEvents
|
|
||||||
_mapHandleOfControlEvent.clear();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -128,15 +126,11 @@ void Control::sendActionsForControlEvents(ControlEvent controlEvents)
|
||||||
invocation->invoke(this);
|
invocation->invoke(this);
|
||||||
}
|
}
|
||||||
//Call ScriptFunc
|
//Call ScriptFunc
|
||||||
if (kScriptTypeNone != _scriptType)
|
if (kScriptTypeLua == _scriptType)
|
||||||
{
|
{
|
||||||
int nHandler = this->getHandleOfControlEvent(controlEvents);
|
cocos2d::BasicScriptData data((void*)this,(void*)&controlEvents);
|
||||||
if (0 != nHandler)
|
cocos2d::ScriptEvent event(cocos2d::kControlEvent,(void*)&data);
|
||||||
{
|
cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
||||||
cocos2d::CommonScriptData data(nHandler, "",(Object*)this);
|
|
||||||
cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
|
|
||||||
cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,30 +332,4 @@ bool Control::hasVisibleParents()
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::addHandleOfControlEvent(int nFunID,ControlEvent controlEvent)
|
|
||||||
{
|
|
||||||
_mapHandleOfControlEvent[controlEvent] = nFunID;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Control::removeHandleOfControlEvent(ControlEvent controlEvent)
|
|
||||||
{
|
|
||||||
std::map<int,int>::iterator Iter = _mapHandleOfControlEvent.find(controlEvent);
|
|
||||||
|
|
||||||
if (_mapHandleOfControlEvent.end() != Iter)
|
|
||||||
{
|
|
||||||
_mapHandleOfControlEvent.erase(Iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int Control::getHandleOfControlEvent(ControlEvent controlEvent)
|
|
||||||
{
|
|
||||||
std::map<int,int>::iterator Iter = _mapHandleOfControlEvent.find(controlEvent);
|
|
||||||
|
|
||||||
if (_mapHandleOfControlEvent.end() != Iter)
|
|
||||||
return Iter->second;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
NS_CC_EXT_END
|
NS_CC_EXT_END
|
||||||
|
|
|
@ -254,13 +254,6 @@ protected:
|
||||||
void removeTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
|
void removeTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
|
||||||
|
|
||||||
static Control* create();
|
static Control* create();
|
||||||
public:
|
|
||||||
void addHandleOfControlEvent(int nFunID,ControlEvent controlEvent);
|
|
||||||
void removeHandleOfControlEvent(ControlEvent controlEvent);
|
|
||||||
private:
|
|
||||||
int getHandleOfControlEvent(ControlEvent controlEvent);
|
|
||||||
private:
|
|
||||||
std::map<int,int> _mapHandleOfControlEvent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of GUI group
|
// end of GUI group
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "LuaOpengl.h"
|
#include "LuaOpengl.h"
|
||||||
#include "LuaScrollView.h"
|
#include "LuaScrollView.h"
|
||||||
|
#include "LuaScriptHandlerMgr.h"
|
||||||
|
|
||||||
using namespace CocosDenshion;
|
using namespace CocosDenshion;
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
#endif
|
#endif
|
||||||
tolua_opengl_open(tolua_s);
|
tolua_opengl_open(tolua_s);
|
||||||
tolua_scroll_view_open(tolua_s);
|
tolua_scroll_view_open(tolua_s);
|
||||||
|
tolua_script_handler_mgr_open(tolua_s);
|
||||||
|
|
||||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
||||||
searchPaths.push_back("cocosbuilderRes");
|
searchPaths.push_back("cocosbuilderRes");
|
||||||
|
@ -74,8 +76,9 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
#endif
|
#endif
|
||||||
FileUtils::getInstance()->setSearchPaths(searchPaths);
|
FileUtils::getInstance()->setSearchPaths(searchPaths);
|
||||||
|
|
||||||
|
pEngine->extendLuaObject();
|
||||||
pEngine->executeScriptFile("luaScript/controller.lua");
|
pEngine->executeScriptFile("luaScript/controller.lua");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ local function CrashTest()
|
||||||
ret:getParent():removeChild(ret, true)
|
ret:getParent():removeChild(ret, true)
|
||||||
Helper.nextAction()
|
Helper.nextAction()
|
||||||
end
|
end
|
||||||
|
local callfunc = CCCallFunc:create(removeThis)
|
||||||
arr:addObject(CCCallFunc:create(removeThis))
|
arr:addObject(callfunc)
|
||||||
--After 1.5 second, self will be removed.
|
--After 1.5 second, self will be removed.
|
||||||
ret:runAction( CCSequence:create(arr))
|
ret:runAction( CCSequence:create(arr))
|
||||||
return ret
|
return ret
|
||||||
|
@ -56,7 +56,8 @@ local function LogicTest()
|
||||||
node:runAction(CCScaleTo:create(2, 2))
|
node:runAction(CCScaleTo:create(2, 2))
|
||||||
end
|
end
|
||||||
|
|
||||||
arr:addObject(CCCallFuncN:create(bugMe))
|
local callfunc = CCCallFunc:create(bugMe)
|
||||||
|
arr:addObject(callfunc)
|
||||||
grossini:runAction( CCSequence:create(arr));
|
grossini:runAction( CCSequence:create(arr));
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
@ -69,7 +70,6 @@ end
|
||||||
|
|
||||||
local function PauseTest()
|
local function PauseTest()
|
||||||
local ret = createTestLayer("Pause Test")
|
local ret = createTestLayer("Pause Test")
|
||||||
|
|
||||||
local schedulerEntry = nil
|
local schedulerEntry = nil
|
||||||
local function unpause(dt)
|
local function unpause(dt)
|
||||||
scheduler:unscheduleScriptEntry(schedulerEntry)
|
scheduler:unscheduleScriptEntry(schedulerEntry)
|
||||||
|
@ -95,6 +95,7 @@ local function PauseTest()
|
||||||
pDirector:getActionManager():addAction(action, grossini, true)
|
pDirector:getActionManager():addAction(action, grossini, true)
|
||||||
|
|
||||||
schedulerEntry = scheduler:scheduleScriptFunc(unpause, 3.0, false)
|
schedulerEntry = scheduler:scheduleScriptFunc(unpause, 3.0, false)
|
||||||
|
|
||||||
elseif event == "exit" then
|
elseif event == "exit" then
|
||||||
if schedulerEntry ~= nil then
|
if schedulerEntry ~= nil then
|
||||||
scheduler:unscheduleScriptEntry(schedulerEntry)
|
scheduler:unscheduleScriptEntry(schedulerEntry)
|
||||||
|
@ -123,10 +124,10 @@ local function RemoveTest()
|
||||||
pSprite:stopActionByTag(kTagSequence)
|
pSprite:stopActionByTag(kTagSequence)
|
||||||
end
|
end
|
||||||
|
|
||||||
local pCallback = CCCallFunc:create(stopAction)
|
local callfunc = CCCallFunc:create(stopAction)
|
||||||
local arr = CCArray:create()
|
local arr = CCArray:create()
|
||||||
arr:addObject(pMove)
|
arr:addObject(pMove)
|
||||||
arr:addObject(pCallback)
|
arr:addObject(callfunc)
|
||||||
local pSequence = CCSequence:create(arr)
|
local pSequence = CCSequence:create(arr)
|
||||||
pSequence:setTag(kTagSequence)
|
pSequence:setTag(kTagSequence)
|
||||||
|
|
||||||
|
|
|
@ -582,25 +582,26 @@ local function ActionSequenceCallback3(sender)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ActionSequence2()
|
local function ActionSequence2()
|
||||||
actionSequenceLayer = CCLayer:create()
|
actionSequenceLayer = CCLayer:create()
|
||||||
initWithLayer(actionSequenceLayer)
|
initWithLayer(actionSequenceLayer)
|
||||||
|
|
||||||
alignSpritesLeft(1)
|
alignSpritesLeft(1)
|
||||||
|
|
||||||
grossini:setVisible(false)
|
grossini:setVisible(false)
|
||||||
local array = CCArray:create()
|
local array = CCArray:create()
|
||||||
array:addObject(CCPlace:create(ccp(200,200)))
|
array:addObject(CCPlace:create(ccp(200,200)))
|
||||||
array:addObject(CCShow:create())
|
array:addObject(CCShow:create())
|
||||||
array:addObject(CCMoveBy:create(1, ccp(100,0)))
|
array:addObject(CCMoveBy:create(1, ccp(100,0)))
|
||||||
array:addObject(CCCallFunc:create(ActionSequenceCallback1))
|
array:addObject(CCCallFunc:create(ActionSequenceCallback1))
|
||||||
array:addObject(CCCallFuncN:create(ActionSequenceCallback2))
|
array:addObject(CCCallFunc:create(ActionSequenceCallback2))
|
||||||
array:addObject(CCCallFuncN:create(ActionSequenceCallback3))
|
array:addObject(CCCallFunc:create(ActionSequenceCallback3))
|
||||||
local action = CCSequence:create(array)
|
|
||||||
|
local action = CCSequence:create(array)
|
||||||
|
|
||||||
grossini:runAction(action)
|
grossini:runAction(action)
|
||||||
|
|
||||||
Helper.subtitleLabel:setString("Sequence of InstantActions")
|
Helper.subtitleLabel:setString("Sequence of InstantActions")
|
||||||
return actionSequenceLayer
|
return actionSequenceLayer
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
|
@ -703,7 +704,7 @@ local function ActionRepeatForever()
|
||||||
|
|
||||||
local action = CCSequence:createWithTwoActions(
|
local action = CCSequence:createWithTwoActions(
|
||||||
CCDelayTime:create(1),
|
CCDelayTime:create(1),
|
||||||
CCCallFuncN:create(repeatForever))
|
CCCallFunc:create(repeatForever) )
|
||||||
|
|
||||||
grossini:runAction(action)
|
grossini:runAction(action)
|
||||||
|
|
||||||
|
@ -796,18 +797,18 @@ local function ActionCallFunc()
|
||||||
|
|
||||||
local action = CCSequence:createWithTwoActions(
|
local action = CCSequence:createWithTwoActions(
|
||||||
CCMoveBy:create(2, ccp(200,0)),
|
CCMoveBy:create(2, ccp(200,0)),
|
||||||
CCCallFunc:create(CallFucnCallback1))
|
CCCallFunc:create(CallFucnCallback1) )
|
||||||
|
|
||||||
local array = CCArray:create()
|
local array = CCArray:create()
|
||||||
array:addObject(CCScaleBy:create(2, 2))
|
array:addObject(CCScaleBy:create(2, 2))
|
||||||
array:addObject(CCFadeOut:create(2))
|
array:addObject(CCFadeOut:create(2))
|
||||||
array:addObject(CCCallFuncN:create(CallFucnCallback2))
|
array:addObject(CCCallFunc:create(CallFucnCallback2))
|
||||||
local action2 = CCSequence:create(array)
|
local action2 = CCSequence:create(array)
|
||||||
|
|
||||||
local array2 = CCArray:create()
|
local array2 = CCArray:create()
|
||||||
array2:addObject(CCRotateBy:create(3 , 360))
|
array2:addObject(CCRotateBy:create(3 , 360))
|
||||||
array2:addObject(CCFadeOut:create(2))
|
array2:addObject(CCFadeOut:create(2))
|
||||||
array2:addObject(CCCallFuncN:create(CallFucnCallback3))
|
array2:addObject(CCCallFunc:create(CallFucnCallback3))
|
||||||
local action3 = CCSequence:create(array2)
|
local action3 = CCSequence:create(array2)
|
||||||
|
|
||||||
grossini:runAction(action)
|
grossini:runAction(action)
|
||||||
|
@ -1087,7 +1088,7 @@ local function ActionIssue1305()
|
||||||
centerSprites(0)
|
centerSprites(0)
|
||||||
|
|
||||||
spriteTmp = CCSprite:create("Images/grossini.png")
|
spriteTmp = CCSprite:create("Images/grossini.png")
|
||||||
spriteTmp:runAction(CCCallFuncN:create(Issue1305_log))
|
spriteTmp:runAction(CCCallFunc:create(Issue1305_log))
|
||||||
|
|
||||||
Issue1305_layer:registerScriptHandler(Issue1305_onEnterOrExit)
|
Issue1305_layer:registerScriptHandler(Issue1305_onEnterOrExit)
|
||||||
|
|
||||||
|
@ -1215,15 +1216,15 @@ local function ActionIssue1327()
|
||||||
spr:setPosition(ccp(100, 100))
|
spr:setPosition(ccp(100, 100))
|
||||||
layer:addChild(spr)
|
layer:addChild(spr)
|
||||||
|
|
||||||
local act1 = CCCallFuncN:create(logSprRotation)
|
local act1 = CCCallFunc:create(logSprRotation)
|
||||||
local act2 = CCRotateBy:create(0.25, 45)
|
local act2 = CCRotateBy:create(0.25, 45)
|
||||||
local act3 = CCCallFuncN:create(logSprRotation)
|
local act3 = CCCallFunc:create(logSprRotation)
|
||||||
local act4 = CCRotateBy:create(0.25, 45)
|
local act4 = CCRotateBy:create(0.25, 45)
|
||||||
local act5 = CCCallFuncN:create(logSprRotation)
|
local act5 = CCCallFunc:create(logSprRotation)
|
||||||
local act6 = CCRotateBy:create(0.25, 45)
|
local act6 = CCRotateBy:create(0.25, 45)
|
||||||
local act7 = CCCallFuncN:create(logSprRotation)
|
local act7 = CCCallFunc:create(logSprRotation)
|
||||||
local act8 = CCRotateBy:create(0.25, 45)
|
local act8 = CCRotateBy:create(0.25, 45)
|
||||||
local act9 = CCCallFuncN:create(logSprRotation)
|
local act9 = CCCallFunc:create(logSprRotation)
|
||||||
|
|
||||||
local array = CCArray:create()
|
local array = CCArray:create()
|
||||||
array:addObject(act1)
|
array:addObject(act1)
|
||||||
|
|
|
@ -128,7 +128,6 @@ local function runNotificationCenterTest()
|
||||||
|
|
||||||
local function setIsConnectToSwitch(pLight,bConnect,nIdx)
|
local function setIsConnectToSwitch(pLight,bConnect,nIdx)
|
||||||
bConnectArray[nIdx] = bConnect
|
bConnectArray[nIdx] = bConnect
|
||||||
print("come in")
|
|
||||||
if bConnect then
|
if bConnect then
|
||||||
CCNotificationCenter:sharedNotificationCenter():registerScriptObserver(pLight, switchStateChanged,NotificationCenterParam.MSG_SWITCH_STATE)
|
CCNotificationCenter:sharedNotificationCenter():registerScriptObserver(pLight, switchStateChanged,NotificationCenterParam.MSG_SWITCH_STATE)
|
||||||
else
|
else
|
||||||
|
@ -372,7 +371,7 @@ local function runCCControlTest()
|
||||||
pDisplayValueLabel:setPosition(ccp(screenSize.width / 1.7, screenSize.height / 2.0))
|
pDisplayValueLabel:setPosition(ccp(screenSize.width / 1.7, screenSize.height / 2.0))
|
||||||
pLayer:addChild(pDisplayValueLabel)
|
pLayer:addChild(pDisplayValueLabel)
|
||||||
|
|
||||||
local function valueChanged(strEventName,pSender)
|
local function valueChanged(pSender)
|
||||||
if nil == pSender or nil == pDisplayValueLabel then
|
if nil == pSender or nil == pDisplayValueLabel then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -397,7 +396,7 @@ local function runCCControlTest()
|
||||||
pSlider:setTag(1)
|
pSlider:setTag(1)
|
||||||
|
|
||||||
--When the value of the slider will change, the given selector will be call
|
--When the value of the slider will change, the given selector will be call
|
||||||
pSlider:addHandleOfControlEvent(valueChanged, CCControlEventValueChanged)
|
pSlider:registerControlEventHandler(valueChanged, CCControlEventValueChanged)
|
||||||
|
|
||||||
local pRestrictSlider = CCControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png")
|
local pRestrictSlider = CCControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png")
|
||||||
pRestrictSlider:setAnchorPoint(ccp(0.5, 1.0))
|
pRestrictSlider:setAnchorPoint(ccp(0.5, 1.0))
|
||||||
|
@ -409,7 +408,7 @@ local function runCCControlTest()
|
||||||
pRestrictSlider:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0 - 24))
|
pRestrictSlider:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0 - 24))
|
||||||
pRestrictSlider:setTag(2)
|
pRestrictSlider:setTag(2)
|
||||||
--same with restricted
|
--same with restricted
|
||||||
pRestrictSlider:addHandleOfControlEvent(valueChanged, CCControlEventValueChanged)
|
pRestrictSlider:registerControlEventHandler(valueChanged, CCControlEventValueChanged)
|
||||||
pLayer:addChild(pSlider)
|
pLayer:addChild(pSlider)
|
||||||
pLayer:addChild(pRestrictSlider)
|
pLayer:addChild(pRestrictSlider)
|
||||||
end
|
end
|
||||||
|
@ -429,7 +428,7 @@ local function runCCControlTest()
|
||||||
local dLayer_width = 0
|
local dLayer_width = 0
|
||||||
|
|
||||||
--Create the colour picker,pStrEventName not use
|
--Create the colour picker,pStrEventName not use
|
||||||
local function colourValueChanged(pStrEventName,pSender)
|
local function colourValueChanged(pSender)
|
||||||
if nil == pSender or nil == pColorLabel then
|
if nil == pSender or nil == pColorLabel then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -441,7 +440,7 @@ local function runCCControlTest()
|
||||||
local pColourPicker = CCControlColourPicker:create()
|
local pColourPicker = CCControlColourPicker:create()
|
||||||
pColourPicker:setColor(Color3B(37, 46, 252))
|
pColourPicker:setColor(Color3B(37, 46, 252))
|
||||||
pColourPicker:setPosition(ccp (pColourPicker:getContentSize().width / 2, 0))
|
pColourPicker:setPosition(ccp (pColourPicker:getContentSize().width / 2, 0))
|
||||||
pColourPicker:addHandleOfControlEvent(colourValueChanged, CCControlEventValueChanged)
|
pColourPicker:registerControlEventHandler(colourValueChanged, CCControlEventValueChanged)
|
||||||
pNode:addChild(pColourPicker)
|
pNode:addChild(pColourPicker)
|
||||||
|
|
||||||
dLayer_width = dLayer_width + pColourPicker:getContentSize().width
|
dLayer_width = dLayer_width + pColourPicker:getContentSize().width
|
||||||
|
@ -463,7 +462,7 @@ local function runCCControlTest()
|
||||||
pNode:setAnchorPoint(ccp (0.5, 0.5))
|
pNode:setAnchorPoint(ccp (0.5, 0.5))
|
||||||
|
|
||||||
--Update the color text
|
--Update the color text
|
||||||
colourValueChanged("", pColourPicker)
|
colourValueChanged(pColourPicker)
|
||||||
end
|
end
|
||||||
|
|
||||||
--SwitchTest
|
--SwitchTest
|
||||||
|
@ -494,7 +493,7 @@ local function runCCControlTest()
|
||||||
pNode:addChild(pDisplayValueLabel)
|
pNode:addChild(pDisplayValueLabel)
|
||||||
|
|
||||||
--Create the switch
|
--Create the switch
|
||||||
local function valueChanged(strEventName,pSender)
|
local function valueChanged(pSender)
|
||||||
if nil == pDisplayValueLabel or nil == pSender then
|
if nil == pDisplayValueLabel or nil == pSender then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -516,14 +515,14 @@ local function runCCControlTest()
|
||||||
)
|
)
|
||||||
pSwitchControl:setPosition(ccp (dLayer_width + 10 + pSwitchControl:getContentSize().width / 2, 0))
|
pSwitchControl:setPosition(ccp (dLayer_width + 10 + pSwitchControl:getContentSize().width / 2, 0))
|
||||||
pNode:addChild(pSwitchControl)
|
pNode:addChild(pSwitchControl)
|
||||||
pSwitchControl:addHandleOfControlEvent(valueChanged, CCControlEventValueChanged)
|
pSwitchControl:registerControlEventHandler(valueChanged, CCControlEventValueChanged)
|
||||||
|
|
||||||
--Set the layer size
|
--Set the layer size
|
||||||
pNode:setContentSize(CCSizeMake(dLayer_width, 0))
|
pNode:setContentSize(CCSizeMake(dLayer_width, 0))
|
||||||
pNode:setAnchorPoint(ccp (0.5, 0.5))
|
pNode:setAnchorPoint(ccp (0.5, 0.5))
|
||||||
|
|
||||||
--Update the value label
|
--Update the value label
|
||||||
valueChanged("", pSwitchControl)
|
valueChanged(pSwitchControl)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Hvs:HelloVariableSize
|
--Hvs:HelloVariableSize
|
||||||
|
@ -731,14 +730,14 @@ local function runCCControlTest()
|
||||||
pControlButton:setTitleColorForState(Color3B(255, 255, 255), CCControlStateHighlighted)
|
pControlButton:setTitleColorForState(Color3B(255, 255, 255), CCControlStateHighlighted)
|
||||||
pControlButton:setAnchorPoint(ccp(0.5, 1))
|
pControlButton:setAnchorPoint(ccp(0.5, 1))
|
||||||
pControlButton:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0))
|
pControlButton:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0))
|
||||||
pControlButton:addHandleOfControlEvent(touchDownAction,CCControlEventTouchDown)
|
pControlButton:registerControlEventHandler(touchDownAction,CCControlEventTouchDown)
|
||||||
pControlButton:addHandleOfControlEvent(touchDragInsideAction,CCControlEventTouchDragInside)
|
pControlButton:registerControlEventHandler(touchDragInsideAction,CCControlEventTouchDragInside)
|
||||||
pControlButton:addHandleOfControlEvent(touchDragOutsideAction,CCControlEventTouchDragOutside)
|
pControlButton:registerControlEventHandler(touchDragOutsideAction,CCControlEventTouchDragOutside)
|
||||||
pControlButton:addHandleOfControlEvent(touchDragEnterAction,CCControlEventTouchDragEnter)
|
pControlButton:registerControlEventHandler(touchDragEnterAction,CCControlEventTouchDragEnter)
|
||||||
pControlButton:addHandleOfControlEvent(touchDragExitAction,CCControlEventTouchDragExit)
|
pControlButton:registerControlEventHandler(touchDragExitAction,CCControlEventTouchDragExit)
|
||||||
pControlButton:addHandleOfControlEvent(touchUpInsideAction,CCControlEventTouchUpInside)
|
pControlButton:registerControlEventHandler(touchUpInsideAction,CCControlEventTouchUpInside)
|
||||||
pControlButton:addHandleOfControlEvent(touchUpOutsideAction,CCControlEventTouchUpOutside)
|
pControlButton:registerControlEventHandler(touchUpOutsideAction,CCControlEventTouchUpOutside)
|
||||||
pControlButton:addHandleOfControlEvent(touchCancelAction,CCControlEventTouchCancel)
|
pControlButton:registerControlEventHandler(touchCancelAction,CCControlEventTouchCancel)
|
||||||
pLayer:addChild(pControlButton, 1)
|
pLayer:addChild(pControlButton, 1)
|
||||||
|
|
||||||
--Add the black background
|
--Add the black background
|
||||||
|
@ -774,7 +773,7 @@ local function runCCControlTest()
|
||||||
pNode:addChild(pDisplayValueLabel)
|
pNode:addChild(pDisplayValueLabel)
|
||||||
|
|
||||||
-- Add the slider
|
-- Add the slider
|
||||||
local function valueChanged(strEventName,pSender)
|
local function valueChanged(pSender)
|
||||||
if nil == pSender then
|
if nil == pSender then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -788,7 +787,7 @@ local function runCCControlTest()
|
||||||
pPotentiometer:setPosition(ccp (dLayer_width + 10 + pPotentiometer:getContentSize().width / 2, 0))
|
pPotentiometer:setPosition(ccp (dLayer_width + 10 + pPotentiometer:getContentSize().width / 2, 0))
|
||||||
|
|
||||||
-- When the value of the slider will change, the given selector will be call
|
-- When the value of the slider will change, the given selector will be call
|
||||||
pPotentiometer:addHandleOfControlEvent(valueChanged, CCControlEventValueChanged)
|
pPotentiometer:registerControlEventHandler(valueChanged, CCControlEventValueChanged)
|
||||||
|
|
||||||
pNode:addChild(pPotentiometer)
|
pNode:addChild(pPotentiometer)
|
||||||
|
|
||||||
|
@ -799,7 +798,7 @@ local function runCCControlTest()
|
||||||
pNode:setAnchorPoint(ccp (0.5, 0.5))
|
pNode:setAnchorPoint(ccp (0.5, 0.5))
|
||||||
|
|
||||||
-- Update the value label
|
-- Update the value label
|
||||||
valueChanged("", pPotentiometer)
|
valueChanged(pPotentiometer)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function InitStepperTest(pLayer)
|
local function InitStepperTest(pLayer)
|
||||||
|
@ -831,7 +830,7 @@ local function runCCControlTest()
|
||||||
local minusSprite = CCSprite:create("extensions/stepper-minus.png")
|
local minusSprite = CCSprite:create("extensions/stepper-minus.png")
|
||||||
local plusSprite = CCSprite:create("extensions/stepper-plus.png")
|
local plusSprite = CCSprite:create("extensions/stepper-plus.png")
|
||||||
|
|
||||||
local function valueChanged(strEventName,pSender)
|
local function valueChanged(pSender)
|
||||||
if nil == pDisplayValueLabel or nil == pSender then
|
if nil == pDisplayValueLabel or nil == pSender then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -842,7 +841,7 @@ local function runCCControlTest()
|
||||||
end
|
end
|
||||||
local stepper = CCControlStepper:create(minusSprite, plusSprite)
|
local stepper = CCControlStepper:create(minusSprite, plusSprite)
|
||||||
stepper:setPosition(ccp (layer_width + 10 + stepper:getContentSize().width / 2, 0))
|
stepper:setPosition(ccp (layer_width + 10 + stepper:getContentSize().width / 2, 0))
|
||||||
stepper:addHandleOfControlEvent(valueChanged, CCControlEventValueChanged)
|
stepper:registerControlEventHandler(valueChanged, CCControlEventValueChanged)
|
||||||
pNode:addChild(stepper)
|
pNode:addChild(stepper)
|
||||||
|
|
||||||
layer_width = layer_width + stepper:getContentSize().width
|
layer_width = layer_width + stepper:getContentSize().width
|
||||||
|
@ -852,7 +851,7 @@ local function runCCControlTest()
|
||||||
pNode:setAnchorPoint(ccp (0.5, 0.5))
|
pNode:setAnchorPoint(ccp (0.5, 0.5))
|
||||||
|
|
||||||
-- Update the value label
|
-- Update the value label
|
||||||
valueChanged("", stepper)
|
valueChanged(stepper)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function InitSpecialSceneLayer(pLayer)
|
local function InitSpecialSceneLayer(pLayer)
|
||||||
|
|
|
@ -313,7 +313,8 @@ local function shouldNotCrash(dt)
|
||||||
explosion:setPosition(s.width / 2, s.height / 2)
|
explosion:setPosition(s.width / 2, s.height / 2)
|
||||||
|
|
||||||
StressTest1_layer:setAnchorPoint(ccp(0, 0))
|
StressTest1_layer:setAnchorPoint(ccp(0, 0))
|
||||||
StressTest1_layer:runAction(CCSequence:createWithTwoActions(CCRotateBy:create(2, 360), CCCallFuncN:create(removeMe)))
|
local callFunc = CCCallFunc:create(removeMe)
|
||||||
|
StressTest1_layer:runAction(CCSequence:createWithTwoActions(CCRotateBy:create(2, 360), callFunc))
|
||||||
|
|
||||||
StressTest1_layer:addChild(explosion)
|
StressTest1_layer:addChild(explosion)
|
||||||
end
|
end
|
||||||
|
|
|
@ -377,9 +377,12 @@ local function TMXReadWriteTest()
|
||||||
local fadein = CCFadeIn:create(2)
|
local fadein = CCFadeIn:create(2)
|
||||||
local scaleback = CCScaleTo:create(1, 1)
|
local scaleback = CCScaleTo:create(1, 1)
|
||||||
|
|
||||||
local function removeSprite(tag, sender)
|
local function removeSprite(sender)
|
||||||
--------cclog("removing tile: %x", sender)
|
--------cclog("removing tile: %x", sender)
|
||||||
local node = tolua.cast(sender, "CCNode");
|
local node = tolua.cast(sender, "CCNode")
|
||||||
|
if nil == node then
|
||||||
|
print("Errro node is nil")
|
||||||
|
end
|
||||||
local p = node:getParent()
|
local p = node:getParent()
|
||||||
|
|
||||||
if p ~= nil then
|
if p ~= nil then
|
||||||
|
@ -388,8 +391,7 @@ local function TMXReadWriteTest()
|
||||||
----------cclog("atlas quantity: %d", p:textureAtlas():totalQuads())
|
----------cclog("atlas quantity: %d", p:textureAtlas():totalQuads())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local finish = CCCallFunc:create(removeSprite)
|
||||||
local finish = CCCallFuncN:create(removeSprite)
|
|
||||||
local arr = CCArray:create()
|
local arr = CCArray:create()
|
||||||
arr:addObject(move)
|
arr:addObject(move)
|
||||||
arr:addObject(rotate)
|
arr:addObject(rotate)
|
||||||
|
|
|
@ -61,8 +61,7 @@ end
|
||||||
|
|
||||||
function schedule(node, callback, delay)
|
function schedule(node, callback, delay)
|
||||||
local delay = CCDelayTime:create(delay)
|
local delay = CCDelayTime:create(delay)
|
||||||
local callfunc = CCCallFunc:create(callback)
|
local sequence = CCSequence:createWithTwoActions(delay, CCCallFunc:create(callback))
|
||||||
local sequence = CCSequence:createWithTwoActions(delay, callfunc)
|
|
||||||
local action = CCRepeatForever:create(sequence)
|
local action = CCRepeatForever:create(sequence)
|
||||||
node:runAction(action)
|
node:runAction(action)
|
||||||
return action
|
return action
|
||||||
|
@ -70,8 +69,7 @@ end
|
||||||
|
|
||||||
function performWithDelay(node, callback, delay)
|
function performWithDelay(node, callback, delay)
|
||||||
local delay = CCDelayTime:create(delay)
|
local delay = CCDelayTime:create(delay)
|
||||||
local callfunc = CCCallFunc:create(callback)
|
local sequence = CCSequence:createWithTwoActions(delay, CCCallFunc:create(callback))
|
||||||
local sequence = CCSequence:createWithTwoActions(delay, callfunc)
|
|
||||||
node:runAction(sequence)
|
node:runAction(sequence)
|
||||||
return sequence
|
return sequence
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,51 +45,50 @@ local BeginPos = {x = 0, y = 0}
|
||||||
|
|
||||||
|
|
||||||
local _allTests = {
|
local _allTests = {
|
||||||
{ isSupported = true, name = "ActionsTest" , create_func = ActionsTest },
|
{ isSupported = true, name = "Accelerometer" , create_func= AccelerometerMain },
|
||||||
{ isSupported = true, name = "TransitionsTest" , create_func = TransitionsTest },
|
|
||||||
{ isSupported = true, name = "ActionsProgressTest" , create_func = ProgressActionsTest },
|
|
||||||
{ isSupported = true, name = "EffectsTest" , create_func = EffectsTest },
|
|
||||||
{ isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest },
|
|
||||||
{ isSupported = true, name = "RotateWorldTest" , create_func = RotateWorldTest },
|
|
||||||
{ isSupported = true, name = "ParticleTest" , create_func = ParticleTest },
|
|
||||||
{ isSupported = true, name = "ActionsEaseTest" , create_func = EaseActionsTest },
|
|
||||||
{ isSupported = true, name = "MotionStreakTest" , create_func = MotionStreakTest },
|
|
||||||
{ isSupported = false, name = "DrawPrimitivesTest" , create_func= DrawPrimitivesTest },
|
|
||||||
{ isSupported = true, name = "NodeTest" , create_func = CocosNodeTest },
|
|
||||||
{ isSupported = true, name = "TouchesTest" , create_func = TouchesTest },
|
|
||||||
--Many tests in MenuTest will crash, so disable it. Should enable it after all crashes are resolved.
|
|
||||||
{ isSupported = true, name = "MenuTest" , create_func = MenuTestMain },
|
|
||||||
{ isSupported = true, name = "ActionManagerTest" , create_func = ActionManagerTestMain },
|
{ isSupported = true, name = "ActionManagerTest" , create_func = ActionManagerTestMain },
|
||||||
{ isSupported = true, name = "LayerTest" , create_func = LayerTestMain },
|
{ isSupported = true, name = "ActionsEaseTest" , create_func = EaseActionsTest },
|
||||||
{ isSupported = true, name = "SceneTest" , create_func = SceneTestMain },
|
{ isSupported = true, name = "ActionsProgressTest" , create_func = ProgressActionsTest },
|
||||||
{ isSupported = true, name = "ParallaxTest" , create_func = ParallaxTestMain },
|
{ isSupported = true, name = "ActionsTest" , create_func = ActionsTest },
|
||||||
{ isSupported = true, name = "TileMapTest" , create_func = TileMapTestMain },
|
|
||||||
{ isSupported = true, name = "IntervalTest" , create_func = IntervalTestMain },
|
|
||||||
{ isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain },
|
|
||||||
{ isSupported = true, name = "LabelTest" , create_func = LabelTest },
|
|
||||||
{ isSupported = false, name = "TextInputTest" , create_func= TextInputTestMain },
|
|
||||||
{ isSupported = true, name = "SpriteTest" , create_func = SpriteTest },
|
|
||||||
{ isSupported = false, name = "SchdulerTest" , create_func= SchdulerTestMain },
|
|
||||||
{ isSupported = true, name = "RenderTextureTest" , create_func = RenderTextureTestMain },
|
|
||||||
{ isSupported = true, name = "Texture2DTest" , create_func = Texture2dTestMain },
|
|
||||||
{ isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain },
|
{ isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain },
|
||||||
{ isSupported = false, name = "Box2dTestBed" , create_func= Box2dTestBedMain },
|
{ isSupported = false, name = "Box2dTestBed" , create_func= Box2dTestBedMain },
|
||||||
{ isSupported = true, name = "EffectAdvancedTest" , create_func = EffectAdvancedTestMain },
|
|
||||||
{ isSupported = true, name = "Accelerometer" , create_func= AccelerometerMain },
|
|
||||||
{ isSupported = true, name = "KeypadTest" , create_func= KeypadTestMain },
|
|
||||||
{ isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain },
|
|
||||||
{ isSupported = true, name = "PerformanceTest" , create_func= PerformanceTestMain },
|
|
||||||
{ isSupported = true, name = "ZwoptexTest" , create_func = ZwoptexTestMain },
|
|
||||||
{ isSupported = false, name = "CurlTest" , create_func= CurlTestMain },
|
|
||||||
{ isSupported = true, name = "UserDefaultTest" , create_func= UserDefaultTestMain },
|
|
||||||
{ isSupported = true, name = "BugsTest" , create_func= BugsTestMain },
|
{ isSupported = true, name = "BugsTest" , create_func= BugsTestMain },
|
||||||
{ isSupported = true, name = "FontTest" , create_func = FontTestMain },
|
{ isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain },
|
||||||
|
{ isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest },
|
||||||
|
{ isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain },
|
||||||
|
{ isSupported = false, name = "CurlTest" , create_func= CurlTestMain },
|
||||||
{ isSupported = true, name = "CurrentLanguageTest" , create_func= CurrentLanguageTestMain },
|
{ isSupported = true, name = "CurrentLanguageTest" , create_func= CurrentLanguageTestMain },
|
||||||
{ isSupported = false, name = "TextureCacheTest" , create_func= TextureCacheTestMain },
|
{ isSupported = false, name = "DrawPrimitivesTest" , create_func= DrawPrimitivesTest },
|
||||||
|
{ isSupported = true, name = "EffectsTest" , create_func = EffectsTest },
|
||||||
|
{ isSupported = true, name = "EffectAdvancedTest" , create_func = EffectAdvancedTestMain },
|
||||||
{ isSupported = true, name = "ExtensionsTest" , create_func= ExtensionsTestMain },
|
{ isSupported = true, name = "ExtensionsTest" , create_func= ExtensionsTestMain },
|
||||||
{ isSupported = false, name = "ShaderTest" , create_func= ShaderTestMain },
|
{ isSupported = true, name = "FontTest" , create_func = FontTestMain },
|
||||||
|
{ isSupported = true, name = "IntervalTest" , create_func = IntervalTestMain },
|
||||||
|
{ isSupported = true, name = "KeypadTest" , create_func= KeypadTestMain },
|
||||||
|
{ isSupported = true, name = "LabelTest" , create_func = LabelTest },
|
||||||
|
{ isSupported = true, name = "LayerTest" , create_func = LayerTestMain },
|
||||||
|
{ isSupported = true, name = "MenuTest" , create_func = MenuTestMain },
|
||||||
|
{ isSupported = true, name = "MotionStreakTest" , create_func = MotionStreakTest },
|
||||||
{ isSupported = false, name = "MutiTouchTest" , create_func= MutiTouchTestMain },
|
{ isSupported = false, name = "MutiTouchTest" , create_func= MutiTouchTestMain },
|
||||||
{ isSupported = true, name = "OpenGLTest" , create_func= OpenGLTestMain }
|
{ isSupported = true, name = "NodeTest" , create_func = CocosNodeTest },
|
||||||
|
{ isSupported = true, name = "OpenGLTest" , create_func= OpenGLTestMain },
|
||||||
|
{ isSupported = true, name = "ParallaxTest" , create_func = ParallaxTestMain },
|
||||||
|
{ isSupported = true, name = "ParticleTest" , create_func = ParticleTest },
|
||||||
|
{ isSupported = true, name = "PerformanceTest" , create_func= PerformanceTestMain },
|
||||||
|
{ isSupported = true, name = "RenderTextureTest" , create_func = RenderTextureTestMain },
|
||||||
|
{ isSupported = true, name = "RotateWorldTest" , create_func = RotateWorldTest },
|
||||||
|
{ isSupported = true, name = "SceneTest" , create_func = SceneTestMain },
|
||||||
|
{ isSupported = false, name = "SchdulerTest" , create_func= SchdulerTestMain },
|
||||||
|
{ isSupported = false, name = "ShaderTest" , create_func= ShaderTestMain },
|
||||||
|
{ isSupported = true, name = "SpriteTest" , create_func = SpriteTest },
|
||||||
|
{ isSupported = false, name = "TextInputTest" , create_func= TextInputTestMain },
|
||||||
|
{ isSupported = true, name = "Texture2DTest" , create_func = Texture2dTestMain },
|
||||||
|
{ isSupported = false, name = "TextureCacheTest" , create_func= TextureCacheTestMain },
|
||||||
|
{ isSupported = true, name = "TileMapTest" , create_func = TileMapTestMain },
|
||||||
|
{ isSupported = true, name = "TouchesTest" , create_func = TouchesTest },
|
||||||
|
{ isSupported = true, name = "TransitionsTest" , create_func = TransitionsTest },
|
||||||
|
{ isSupported = true, name = "UserDefaultTest" , create_func= UserDefaultTestMain },
|
||||||
|
{ isSupported = true, name = "ZwoptexTest" , create_func = ZwoptexTestMain }
|
||||||
}
|
}
|
||||||
|
|
||||||
local TESTS_COUNT = table.getn(_allTests)
|
local TESTS_COUNT = table.getn(_allTests)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "CCBProxy.h"
|
#include "CCBProxy.h"
|
||||||
|
#include "LuaScriptHandlerMgr.h"
|
||||||
|
|
||||||
CCBReader* CCBProxy::createCCBReader()
|
CCBReader* CCBProxy::createCCBReader()
|
||||||
{
|
{
|
||||||
|
@ -144,7 +145,7 @@ void CCBProxy::setCallback(Node* pNode,int nHandle)
|
||||||
{
|
{
|
||||||
MenuItem *pMenuItem = dynamic_cast<MenuItem*>(pNode);
|
MenuItem *pMenuItem = dynamic_cast<MenuItem*>(pNode);
|
||||||
if (NULL != pMenuItem) {
|
if (NULL != pMenuItem) {
|
||||||
pMenuItem->registerScriptTapHandler(nHandle);
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)pMenuItem, nHandle, ScriptHandlerMgr::kMenuClickHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (NULL != dynamic_cast<ControlButton*>(pNode))
|
else if (NULL != dynamic_cast<ControlButton*>(pNode))
|
||||||
|
@ -152,10 +153,8 @@ void CCBProxy::setCallback(Node* pNode,int nHandle)
|
||||||
ControlButton *pBtnItem = dynamic_cast<ControlButton*>(pNode);
|
ControlButton *pBtnItem = dynamic_cast<ControlButton*>(pNode);
|
||||||
if (NULL != pBtnItem) {
|
if (NULL != pBtnItem) {
|
||||||
//UNOD,need Btn Pros to addHanldeOfControlEvent
|
//UNOD,need Btn Pros to addHanldeOfControlEvent
|
||||||
pBtnItem->addHandleOfControlEvent(nHandle,ControlEventTouchUpInside);
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)pBtnItem, nHandle, ScriptHandlerMgr::kControlTouchUpInsideHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
#include "cocoa/CCArray.h"
|
#include "cocoa/CCArray.h"
|
||||||
#include "CCScheduler.h"
|
#include "CCScheduler.h"
|
||||||
|
#include "LuaScriptHandlerMgr.h"
|
||||||
|
#include "GUI/CCControlExtension/CCControl.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
@ -67,6 +69,7 @@ void LuaEngine::addLuaLoader(lua_CFunction func)
|
||||||
void LuaEngine::removeScriptObjectByObject(Object* pObj)
|
void LuaEngine::removeScriptObjectByObject(Object* pObj)
|
||||||
{
|
{
|
||||||
_stack->removeScriptObjectByObject(pObj);
|
_stack->removeScriptObjectByObject(pObj);
|
||||||
|
ScriptHandlerMgr::getInstance()->removeObjectAllHandlers(pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaEngine::removeScriptHandler(int nHandler)
|
void LuaEngine::removeScriptHandler(int nHandler)
|
||||||
|
@ -97,49 +100,12 @@ int LuaEngine::executeGlobalFunction(const char* functionName)
|
||||||
|
|
||||||
int LuaEngine::executeNodeEvent(Node* pNode, int nAction)
|
int LuaEngine::executeNodeEvent(Node* pNode, int nAction)
|
||||||
{
|
{
|
||||||
int nHandler = pNode->getScriptHandler();
|
return 0;
|
||||||
if (!nHandler) return 0;
|
|
||||||
|
|
||||||
switch (nAction)
|
|
||||||
{
|
|
||||||
case kNodeOnEnter:
|
|
||||||
_stack->pushString("enter");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kNodeOnExit:
|
|
||||||
_stack->pushString("exit");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kNodeOnEnterTransitionDidFinish:
|
|
||||||
_stack->pushString("enterTransitionFinish");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kNodeOnExitTransitionDidStart:
|
|
||||||
_stack->pushString("exitTransitionStart");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kNodeOnCleanup:
|
|
||||||
_stack->pushString("cleanup");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int ret = _stack->executeFunctionByHandler(nHandler, 1);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::executeMenuItemEvent(MenuItem* pMenuItem)
|
int LuaEngine::executeMenuItemEvent(MenuItem* pMenuItem)
|
||||||
{
|
{
|
||||||
int nHandler = pMenuItem->getScriptTapHandler();
|
return 0;
|
||||||
if (!nHandler) return 0;
|
|
||||||
|
|
||||||
_stack->pushInt(pMenuItem->getTag());
|
|
||||||
_stack->pushObject(pMenuItem, "CCMenuItem");
|
|
||||||
int ret = _stack->executeFunctionByHandler(nHandler, 2);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::executeNotificationEvent(NotificationCenter* pNotificationCenter, const char* pszName)
|
int LuaEngine::executeNotificationEvent(NotificationCenter* pNotificationCenter, const char* pszName)
|
||||||
|
@ -155,16 +121,7 @@ int LuaEngine::executeNotificationEvent(NotificationCenter* pNotificationCenter,
|
||||||
|
|
||||||
int LuaEngine::executeCallFuncActionEvent(CallFunc* pAction, Object* pTarget/* = NULL*/)
|
int LuaEngine::executeCallFuncActionEvent(CallFunc* pAction, Object* pTarget/* = NULL*/)
|
||||||
{
|
{
|
||||||
int nHandler = pAction->getScriptHandler();
|
return 0;
|
||||||
if (!nHandler) return 0;
|
|
||||||
|
|
||||||
if (pTarget)
|
|
||||||
{
|
|
||||||
_stack->pushObject(pTarget, "CCNode");
|
|
||||||
}
|
|
||||||
int ret = _stack->executeFunctionByHandler(nHandler, pTarget ? 1 : 0);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::executeSchedule(int nHandler, float dt, Node* pNode/* = NULL*/)
|
int LuaEngine::executeSchedule(int nHandler, float dt, Node* pNode/* = NULL*/)
|
||||||
|
@ -178,131 +135,22 @@ int LuaEngine::executeSchedule(int nHandler, float dt, Node* pNode/* = NULL*/)
|
||||||
|
|
||||||
int LuaEngine::executeLayerTouchEvent(Layer* pLayer, int eventType, Touch *pTouch)
|
int LuaEngine::executeLayerTouchEvent(Layer* pLayer, int eventType, Touch *pTouch)
|
||||||
{
|
{
|
||||||
TouchScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptTouchHandlerEntry();
|
return 0;
|
||||||
if (!pScriptHandlerEntry) return 0;
|
|
||||||
int nHandler = pScriptHandlerEntry->getHandler();
|
|
||||||
if (!nHandler) return 0;
|
|
||||||
|
|
||||||
switch (eventType)
|
|
||||||
{
|
|
||||||
case CCTOUCHBEGAN:
|
|
||||||
_stack->pushString("began");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CCTOUCHMOVED:
|
|
||||||
_stack->pushString("moved");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CCTOUCHENDED:
|
|
||||||
_stack->pushString("ended");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CCTOUCHCANCELLED:
|
|
||||||
_stack->pushString("cancelled");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Point pt = Director::getInstance()->convertToGL(pTouch->getLocationInView());
|
|
||||||
_stack->pushFloat(pt.x);
|
|
||||||
_stack->pushFloat(pt.y);
|
|
||||||
int ret = _stack->executeFunctionByHandler(nHandler, 3);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::executeLayerTouchesEvent(Layer* pLayer, int eventType, Set *pTouches)
|
int LuaEngine::executeLayerTouchesEvent(Layer* pLayer, int eventType, Set *pTouches)
|
||||||
{
|
{
|
||||||
TouchScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptTouchHandlerEntry();
|
return 0;
|
||||||
if (!pScriptHandlerEntry) return 0;
|
|
||||||
int nHandler = pScriptHandlerEntry->getHandler();
|
|
||||||
if (!nHandler) return 0;
|
|
||||||
|
|
||||||
switch (eventType)
|
|
||||||
{
|
|
||||||
case CCTOUCHBEGAN:
|
|
||||||
_stack->pushString("began");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CCTOUCHMOVED:
|
|
||||||
_stack->pushString("moved");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CCTOUCHENDED:
|
|
||||||
_stack->pushString("ended");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CCTOUCHCANCELLED:
|
|
||||||
_stack->pushString("cancelled");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Director* pDirector = Director::getInstance();
|
|
||||||
lua_State *L = _stack->getLuaState();
|
|
||||||
lua_newtable(L);
|
|
||||||
int i = 1;
|
|
||||||
for (SetIterator it = pTouches->begin(); it != pTouches->end(); ++it)
|
|
||||||
{
|
|
||||||
Touch* pTouch = (Touch*)*it;
|
|
||||||
Point pt = pDirector->convertToGL(pTouch->getLocationInView());
|
|
||||||
lua_pushnumber(L, pt.x);
|
|
||||||
lua_rawseti(L, -2, i++);
|
|
||||||
lua_pushnumber(L, pt.y);
|
|
||||||
lua_rawseti(L, -2, i++);
|
|
||||||
lua_pushinteger(L, pTouch->getID());
|
|
||||||
lua_rawseti(L, -2, i++);
|
|
||||||
}
|
|
||||||
int ret = _stack->executeFunctionByHandler(nHandler, 2);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::executeLayerKeypadEvent(Layer* pLayer, int eventType)
|
int LuaEngine::executeLayerKeypadEvent(Layer* pLayer, int eventType)
|
||||||
{
|
{
|
||||||
ScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptKeypadHandlerEntry();
|
return 0;
|
||||||
if (!pScriptHandlerEntry)
|
|
||||||
return 0;
|
|
||||||
int nHandler = pScriptHandlerEntry->getHandler();
|
|
||||||
if (!nHandler) return 0;
|
|
||||||
|
|
||||||
switch (eventType)
|
|
||||||
{
|
|
||||||
case kTypeBackClicked:
|
|
||||||
_stack->pushString("backClicked");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kTypeMenuClicked:
|
|
||||||
_stack->pushString("menuClicked");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int ret = _stack->executeFunctionByHandler(nHandler, 1);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::executeAccelerometerEvent(Layer* pLayer, Acceleration* pAccelerationValue)
|
int LuaEngine::executeAccelerometerEvent(Layer* pLayer, Acceleration* pAccelerationValue)
|
||||||
{
|
{
|
||||||
ScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptAccelerateHandlerEntry();
|
return 0;
|
||||||
if (!pScriptHandlerEntry)
|
|
||||||
return 0;
|
|
||||||
int nHandler = pScriptHandlerEntry->getHandler();
|
|
||||||
if (!nHandler) return 0;
|
|
||||||
|
|
||||||
_stack->pushFloat(pAccelerationValue->x);
|
|
||||||
_stack->pushFloat(pAccelerationValue->y);
|
|
||||||
_stack->pushFloat(pAccelerationValue->z);
|
|
||||||
_stack->pushFloat(pAccelerationValue->timestamp);
|
|
||||||
int ret = _stack->executeFunctionByHandler(nHandler, 4);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::executeEvent(int nHandler, const char* pEventName, Object* pEventSource /* = NULL*/, const char* pEventSourceClassName /* = NULL*/)
|
int LuaEngine::executeEvent(int nHandler, const char* pEventName, Object* pEventSource /* = NULL*/, const char* pEventSourceClassName /* = NULL*/)
|
||||||
|
@ -382,6 +230,11 @@ int LuaEngine::sendEvent(ScriptEvent* message)
|
||||||
return handleCommonEvent(message->data);
|
return handleCommonEvent(message->data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case kControlEvent:
|
||||||
|
{
|
||||||
|
return handlerControlEvent(message->data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -398,9 +251,8 @@ int LuaEngine::handleNodeEvent(void* data)
|
||||||
if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value)
|
if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Node* node = (Node*)(basicScriptData->nativeObject);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::kNodeHandler);
|
||||||
|
|
||||||
int handler = node->getScriptHandler();
|
|
||||||
if (0 == handler)
|
if (0 == handler)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -446,7 +298,7 @@ int LuaEngine::handleMenuClickedEvent(void* data)
|
||||||
|
|
||||||
MenuItem* menuItem = (MenuItem*)(basicScriptData->nativeObject);
|
MenuItem* menuItem = (MenuItem*)(basicScriptData->nativeObject);
|
||||||
|
|
||||||
int handler = menuItem->getScriptTapHandler();
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)menuItem, ScriptHandlerMgr::kMenuClickHandler);
|
||||||
if (0 == handler)
|
if (0 == handler)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -487,9 +339,12 @@ int LuaEngine::handleCallFuncActionEvent(void* data)
|
||||||
BasicScriptData* basicScriptData = (BasicScriptData*)(data);
|
BasicScriptData* basicScriptData = (BasicScriptData*)(data);
|
||||||
if (NULL == basicScriptData->nativeObject)
|
if (NULL == basicScriptData->nativeObject)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
int handler =ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::kCallFuncHandler);
|
||||||
|
|
||||||
|
if (0 == handler)
|
||||||
|
return 0;
|
||||||
|
|
||||||
CallFunc* callFunc = (CallFunc*)(basicScriptData->nativeObject);
|
|
||||||
int handler = callFunc->getScriptHandler();
|
|
||||||
Object* target = (Object*)(basicScriptData->value);
|
Object* target = (Object*)(basicScriptData->value);
|
||||||
if (NULL != target)
|
if (NULL != target)
|
||||||
{
|
{
|
||||||
|
@ -523,20 +378,29 @@ int LuaEngine::handleKeypadEvent(void* data)
|
||||||
if (NULL == keypadScriptData->nativeObject)
|
if (NULL == keypadScriptData->nativeObject)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (keypadScriptData->objectType)
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)keypadScriptData->nativeObject, ScriptHandlerMgr::kKeypadHandler);
|
||||||
|
|
||||||
|
if (0 == handler)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int action = keypadScriptData->actionType;
|
||||||
|
|
||||||
|
switch (action)
|
||||||
{
|
{
|
||||||
case kLayerKeypad:
|
case kTypeBackClicked:
|
||||||
{
|
_stack->pushString("backClicked");
|
||||||
Layer* layer = (Layer*)(keypadScriptData->nativeObject);
|
break;
|
||||||
return handleLayerKeypadEvent(layer, keypadScriptData->actionType);
|
|
||||||
}
|
case kTypeMenuClicked:
|
||||||
break;
|
_stack->pushString("menuClicked");
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int ret = _stack->executeFunctionByHandler(handler, 1);
|
||||||
return 0;
|
_stack->clean();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::handleAccelerometerEvent(void* data)
|
int LuaEngine::handleAccelerometerEvent(void* data)
|
||||||
|
@ -548,10 +412,8 @@ int LuaEngine::handleAccelerometerEvent(void* data)
|
||||||
if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value)
|
if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Layer* layer = (Layer*)(basicScriptData->nativeObject);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::kAccelerometerHandler);
|
||||||
|
if (0 == handler)
|
||||||
ScriptHandlerEntry* scriptHandlerEntry = layer->getScriptAccelerateHandlerEntry();
|
|
||||||
if (NULL == scriptHandlerEntry || 0 == scriptHandlerEntry->getHandler())
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Acceleration* accelerationValue = (Acceleration*)(basicScriptData->value);
|
Acceleration* accelerationValue = (Acceleration*)(basicScriptData->value);
|
||||||
|
@ -559,7 +421,7 @@ int LuaEngine::handleAccelerometerEvent(void* data)
|
||||||
_stack->pushFloat(accelerationValue->y);
|
_stack->pushFloat(accelerationValue->y);
|
||||||
_stack->pushFloat(accelerationValue->z);
|
_stack->pushFloat(accelerationValue->z);
|
||||||
_stack->pushFloat(accelerationValue->timestamp);
|
_stack->pushFloat(accelerationValue->timestamp);
|
||||||
int ret = _stack->executeFunctionByHandler(scriptHandlerEntry->getHandler(), 4);
|
int ret = _stack->executeFunctionByHandler(handler, 4);
|
||||||
_stack->clean();
|
_stack->clean();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -599,32 +461,12 @@ int LuaEngine::handleTouchesEvent(void* data)
|
||||||
if (NULL == touchesScriptData->nativeObject || NULL == touchesScriptData->touches)
|
if (NULL == touchesScriptData->nativeObject || NULL == touchesScriptData->touches)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (touchesScriptData->objectType)
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)touchesScriptData->nativeObject, ScriptHandlerMgr::kTouchesHandler);
|
||||||
{
|
|
||||||
case kLayerTouches:
|
if (0 == handler)
|
||||||
{
|
|
||||||
Layer* layer = (Layer*)(touchesScriptData->nativeObject);
|
|
||||||
return handleLayerTouchesEvent(layer, touchesScriptData->actionType, touchesScriptData->touches);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LuaEngine::handleLayerTouchesEvent(Layer* layer,int actionType,Set* touches)
|
|
||||||
{
|
|
||||||
if (NULL == layer || NULL == touches)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
TouchScriptHandlerEntry* scriptHandlerEntry = layer->getScriptTouchHandlerEntry();
|
switch (touchesScriptData->actionType)
|
||||||
if (NULL == scriptHandlerEntry || 0 == scriptHandlerEntry->getHandler())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch (actionType)
|
|
||||||
{
|
{
|
||||||
case CCTOUCHBEGAN:
|
case CCTOUCHBEGAN:
|
||||||
_stack->pushString("began");
|
_stack->pushString("began");
|
||||||
|
@ -648,23 +490,23 @@ int LuaEngine::handleLayerTouchesEvent(Layer* layer,int actionType,Set* touches)
|
||||||
|
|
||||||
Director* pDirector = Director::getInstance();
|
Director* pDirector = Director::getInstance();
|
||||||
lua_State *L = _stack->getLuaState();
|
lua_State *L = _stack->getLuaState();
|
||||||
int count = touches->count();
|
int count = touchesScriptData->touches->count();
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
Touch* touch = (Touch*)*(touches->begin());
|
Touch* touch = (Touch*)*(touchesScriptData->touches->begin());
|
||||||
if (NULL != touch) {
|
if (NULL != touch) {
|
||||||
const Point pt = Director::getInstance()->convertToGL(touch->getLocationInView());
|
const Point pt = Director::getInstance()->convertToGL(touch->getLocationInView());
|
||||||
_stack->pushFloat(pt.x);
|
_stack->pushFloat(pt.x);
|
||||||
_stack->pushFloat(pt.y);
|
_stack->pushFloat(pt.y);
|
||||||
ret = _stack->executeFunctionByHandler(scriptHandlerEntry->getHandler(), 3);
|
ret = _stack->executeFunctionByHandler(handler, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(count > 1)
|
else if(count > 1)
|
||||||
{
|
{
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (SetIterator it = touches->begin(); it != touches->end(); ++it)
|
for (SetIterator it = touchesScriptData->touches->begin(); it != touchesScriptData->touches->end(); ++it)
|
||||||
{
|
{
|
||||||
Touch* pTouch = (Touch*)*it;
|
Touch* pTouch = (Touch*)*it;
|
||||||
Point pt = pDirector->convertToGL(pTouch->getLocationInView());
|
Point pt = pDirector->convertToGL(pTouch->getLocationInView());
|
||||||
|
@ -675,36 +517,139 @@ int LuaEngine::handleLayerTouchesEvent(Layer* layer,int actionType,Set* touches)
|
||||||
lua_pushinteger(L, pTouch->getID());
|
lua_pushinteger(L, pTouch->getID());
|
||||||
lua_rawseti(L, -2, i++);
|
lua_rawseti(L, -2, i++);
|
||||||
}
|
}
|
||||||
ret = _stack->executeFunctionByHandler(scriptHandlerEntry->getHandler(), 2);
|
ret = _stack->executeFunctionByHandler(handler, 2);
|
||||||
}
|
}
|
||||||
_stack->clean();
|
_stack->clean();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::handleLayerKeypadEvent(Layer* layer,int actionType)
|
int LuaEngine::handlerControlEvent(void* data)
|
||||||
{
|
{
|
||||||
if (NULL == layer)
|
if ( NULL == data )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ScriptHandlerEntry* pScriptHandlerEntry = layer->getScriptKeypadHandlerEntry();
|
BasicScriptData* basicScriptData = (BasicScriptData*)data;
|
||||||
|
if (NULL == basicScriptData->nativeObject)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int action = actionType;
|
int controlEvents = *((int*)(basicScriptData->value));
|
||||||
|
|
||||||
switch (action)
|
int handler = 0;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||||
{
|
{
|
||||||
case kTypeBackClicked:
|
if ((controlEvents & (1 << i)))
|
||||||
_stack->pushString("backClicked");
|
{
|
||||||
break;
|
handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::kControlTouchDownHandler + i);
|
||||||
|
|
||||||
case kTypeMenuClicked:
|
if (0 != handler)
|
||||||
_stack->pushString("menuClicked");
|
{
|
||||||
break;
|
_stack->pushObject((Object*)basicScriptData->nativeObject, "CCObject");
|
||||||
|
ret = _stack->executeFunctionByHandler(handler, 1);
|
||||||
default:
|
_stack->clean();
|
||||||
return 0;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int ret = _stack->executeFunctionByHandler(pScriptHandlerEntry->getHandler(), 1);
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaEngine::extendLuaObject()
|
||||||
|
{
|
||||||
|
if ( NULL == _stack || NULL == _stack->getLuaState())
|
||||||
|
return;
|
||||||
|
|
||||||
|
lua_State* lua_S = _stack->getLuaState();
|
||||||
|
extendNode(lua_S);
|
||||||
|
extendMenuItem(lua_S);
|
||||||
|
extendLayer(lua_S);
|
||||||
|
extendControl(lua_S);
|
||||||
|
|
||||||
_stack->clean();
|
_stack->clean();
|
||||||
return ret;
|
}
|
||||||
|
|
||||||
|
void LuaEngine::extendNode(lua_State* lua_S)
|
||||||
|
{
|
||||||
|
if(NULL == lua_S)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lua_pushstring(lua_S,"CCNode");
|
||||||
|
lua_rawget(lua_S,LUA_REGISTRYINDEX);
|
||||||
|
if (lua_istable(lua_S,-1))
|
||||||
|
{
|
||||||
|
lua_pushstring(lua_S,"registerScriptHandler");
|
||||||
|
lua_pushcfunction(lua_S,tolua_Cocos2d_registerScriptHandler00);
|
||||||
|
lua_rawset(lua_S,-3);
|
||||||
|
lua_pushstring(lua_S,"unregisterScriptHandler");
|
||||||
|
lua_pushcfunction(lua_S,tolua_Cocos2d_unregisterScriptHandler00);
|
||||||
|
lua_rawset(lua_S, -3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaEngine::extendMenuItem(lua_State* lua_S)
|
||||||
|
{
|
||||||
|
if (NULL == lua_S)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lua_pushstring(lua_S,"CCMenuItem");
|
||||||
|
lua_rawget(lua_S,LUA_REGISTRYINDEX);
|
||||||
|
if (lua_istable(lua_S,-1))
|
||||||
|
{
|
||||||
|
lua_pushstring(lua_S,"registerScriptTapHandler");
|
||||||
|
lua_pushcfunction(lua_S,tolua_Cocos2d_registerScriptTapHandler00);
|
||||||
|
lua_rawset(lua_S,-3);
|
||||||
|
lua_pushstring(lua_S, "unregisterScriptTapHandler");
|
||||||
|
lua_pushcfunction(lua_S,tolua_Cocos2d_unregisterScriptTapHandler00);
|
||||||
|
lua_rawset(lua_S, -3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaEngine::extendLayer(lua_State* lua_S)
|
||||||
|
{
|
||||||
|
if (NULL == lua_S)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lua_pushstring(lua_S,"CCLayer");
|
||||||
|
lua_rawget(lua_S,LUA_REGISTRYINDEX);
|
||||||
|
if (lua_istable(lua_S,-1))
|
||||||
|
{
|
||||||
|
lua_pushstring(lua_S,"registerScriptTouchHandler");
|
||||||
|
lua_pushcfunction(lua_S,tolua_Cocos2d_registerScriptTouchHandler00);
|
||||||
|
lua_rawset(lua_S,-3);
|
||||||
|
lua_pushstring(lua_S, "unregisterScriptTouchHandler");
|
||||||
|
lua_pushcfunction(lua_S,tolua_Cocos2d_unregisterScriptTouchHandler00);
|
||||||
|
lua_rawset(lua_S, -3);
|
||||||
|
lua_pushstring(lua_S, "registerScriptKeypadHandler");
|
||||||
|
lua_pushcfunction(lua_S, tolua_Cocos2d_registerScriptKeypadHandler00);
|
||||||
|
lua_rawset(lua_S, -3);
|
||||||
|
lua_pushstring(lua_S, "unregisterScriptKeypadHandler");
|
||||||
|
lua_pushcfunction(lua_S, tolua_Cocos2d_unregisterScriptKeypadHandler00);
|
||||||
|
lua_rawset(lua_S, -3);
|
||||||
|
lua_pushstring(lua_S, "registerScriptAccelerateHandler");
|
||||||
|
lua_pushcfunction(lua_S, tolua_Cocos2d_registerScriptAccelerateHandler00);
|
||||||
|
lua_rawset(lua_S, -3);
|
||||||
|
lua_pushstring(lua_S, "unregisterScriptAccelerateHandler");
|
||||||
|
lua_pushcfunction(lua_S, tolua_Cocos2d_unregisterScriptAccelerateHandler00);
|
||||||
|
lua_rawset(lua_S, -3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaEngine::extendControl(lua_State* lua_S)
|
||||||
|
{
|
||||||
|
if (NULL == lua_S)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lua_pushstring(lua_S,"CCControl");
|
||||||
|
lua_rawget(lua_S,LUA_REGISTRYINDEX);
|
||||||
|
if (lua_istable(lua_S,-1))
|
||||||
|
{
|
||||||
|
lua_pushstring(lua_S,"registerControlEventHandler");
|
||||||
|
lua_pushcfunction(lua_S,tolua_Cocos2d_registerControlEventHandler00);
|
||||||
|
lua_rawset(lua_S,-3);
|
||||||
|
lua_pushstring(lua_S,"unregisterControlEventHandler");
|
||||||
|
lua_pushcfunction(lua_S,tolua_Cocos2d_unregisterControlEventHandler00);
|
||||||
|
lua_rawset(lua_S,-3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -119,6 +119,7 @@ public:
|
||||||
virtual bool handleAssert(const char *msg);
|
virtual bool handleAssert(const char *msg);
|
||||||
|
|
||||||
virtual int sendEvent(ScriptEvent* message);
|
virtual int sendEvent(ScriptEvent* message);
|
||||||
|
void extendLuaObject();
|
||||||
private:
|
private:
|
||||||
int handleNodeEvent(void* data);
|
int handleNodeEvent(void* data);
|
||||||
int handleMenuClickedEvent(void* data);
|
int handleMenuClickedEvent(void* data);
|
||||||
|
@ -129,8 +130,11 @@ private:
|
||||||
int handleAccelerometerEvent(void* data);
|
int handleAccelerometerEvent(void* data);
|
||||||
int handleCommonEvent(void* data);
|
int handleCommonEvent(void* data);
|
||||||
int handleTouchesEvent(void* data);
|
int handleTouchesEvent(void* data);
|
||||||
int handleLayerTouchesEvent(Layer* layer,int actionType,Set* touches);
|
int handlerControlEvent(void* data);
|
||||||
int handleLayerKeypadEvent(Layer* layer,int actionType);
|
void extendNode(lua_State* lua_S);
|
||||||
|
void extendMenuItem(lua_State* lua_S);
|
||||||
|
void extendLayer(lua_State* lua_S);
|
||||||
|
void extendControl(lua_State* lua_S);
|
||||||
private:
|
private:
|
||||||
LuaEngine(void)
|
LuaEngine(void)
|
||||||
: _stack(NULL)
|
: _stack(NULL)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
dcb1aae4641e4e318fc42f8d740bebe21c4277ca
|
ecb6191757f5eb70142d6767d49edf46074a2db4
|
|
@ -1 +1 @@
|
||||||
d0b231fcad3b4e35d4f2a998dce1b7437ae689ab
|
9fac9e19f8a57d40eb90b02c0be6e9f8e20e0d22
|
|
@ -0,0 +1,610 @@
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#include "tolua_fix.h"
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include "LuaScriptHandlerMgr.h"
|
||||||
|
#include "cocos2d.h"
|
||||||
|
#include "cocos-ext.h"
|
||||||
|
#include "CCLuaStack.h"
|
||||||
|
#include "CCLuaValue.h"
|
||||||
|
#include "CCLuaEngine.h"
|
||||||
|
|
||||||
|
using namespace cocos2d;
|
||||||
|
using namespace cocos2d::extension;
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
ScheduleHandlerDelegate* ScheduleHandlerDelegate::create()
|
||||||
|
{
|
||||||
|
ScheduleHandlerDelegate *ret = new ScheduleHandlerDelegate();
|
||||||
|
if (NULL != ret )
|
||||||
|
{
|
||||||
|
ret->autorelease();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScheduleHandlerDelegate::scheduleFunc(float elapse)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScheduleHandlerDelegate::update(float elapse)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LuaCallFunc * LuaCallFunc::create(int nHandler)
|
||||||
|
{
|
||||||
|
LuaCallFunc *ret = new LuaCallFunc();
|
||||||
|
if (NULL != ret )
|
||||||
|
{
|
||||||
|
ret->autorelease();
|
||||||
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)ret, nHandler, ScriptHandlerMgr::kCallFuncHandler);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void LuaCallFunc::execute()
|
||||||
|
{
|
||||||
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr:: kCallFuncHandler);
|
||||||
|
|
||||||
|
if (0 == handler)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
BasicScriptData data((void*)this,(void*)_target);
|
||||||
|
ScriptEvent event(kCallFuncEvent,(void*)&data);
|
||||||
|
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaCallFunc* LuaCallFunc::clone() const
|
||||||
|
{
|
||||||
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr:: kCallFuncHandler);
|
||||||
|
|
||||||
|
if (0 == handler)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
auto ret = new LuaCallFunc();
|
||||||
|
|
||||||
|
int newscriptHandler = cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->reallocateScriptHandler(handler);
|
||||||
|
|
||||||
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)ret, newscriptHandler, ScriptHandlerMgr::kCallFuncHandler);
|
||||||
|
|
||||||
|
ret->autorelease();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptHandlerMgr* ScriptHandlerMgr::_scriptHandlerMgr = NULL;
|
||||||
|
|
||||||
|
ScriptHandlerMgr::ScriptHandlerMgr()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
ScriptHandlerMgr::~ScriptHandlerMgr()
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE(_scriptHandlerMgr);
|
||||||
|
}
|
||||||
|
ScriptHandlerMgr* ScriptHandlerMgr::getInstance()
|
||||||
|
{
|
||||||
|
if (NULL == _scriptHandlerMgr)
|
||||||
|
{
|
||||||
|
_scriptHandlerMgr = new ScriptHandlerMgr();
|
||||||
|
_scriptHandlerMgr->init();
|
||||||
|
}
|
||||||
|
return _scriptHandlerMgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptHandlerMgr::init()
|
||||||
|
{
|
||||||
|
_mapObjectHandlers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptHandlerMgr::addObjectHandler(void* object,int handler,int eventType)
|
||||||
|
{
|
||||||
|
if (NULL == object)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//may be not need
|
||||||
|
removeObjectHandler(object,eventType);
|
||||||
|
|
||||||
|
auto iter = _mapObjectHandlers.find(object);
|
||||||
|
VecEventHandlers vecHandlers;
|
||||||
|
vecHandlers.clear();
|
||||||
|
if (_mapObjectHandlers.end() != iter)
|
||||||
|
{
|
||||||
|
vecHandlers = iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
PairEventHandler eventHanler = std::make_pair(eventType, handler);
|
||||||
|
vecHandlers.push_back(eventHanler);
|
||||||
|
_mapObjectHandlers[object] = vecHandlers;
|
||||||
|
}
|
||||||
|
void ScriptHandlerMgr::removeObjectHandler(void* object,int eventType)
|
||||||
|
{
|
||||||
|
if (NULL == object || _mapObjectHandlers.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto iterMap = _mapObjectHandlers.find(object);
|
||||||
|
if (_mapObjectHandlers.end() == iterMap)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (iterMap->second.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto iterVec = iterMap->second.begin();
|
||||||
|
bool exist = false;
|
||||||
|
for (; iterVec != iterMap->second.end(); iterVec++)
|
||||||
|
{
|
||||||
|
if (iterVec->first == eventType)
|
||||||
|
{
|
||||||
|
exist = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exist)
|
||||||
|
{
|
||||||
|
iterMap->second.erase(iterVec);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
int ScriptHandlerMgr::getObjectHandler(void* object,int eventType)
|
||||||
|
{
|
||||||
|
if (NULL == object || _mapObjectHandlers.empty() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
auto iter = _mapObjectHandlers.find(object);
|
||||||
|
|
||||||
|
if (_mapObjectHandlers.end() != iter)
|
||||||
|
{
|
||||||
|
auto iterVec = (iter->second).begin();
|
||||||
|
for (; iterVec != (iter->second).end(); iterVec++)
|
||||||
|
{
|
||||||
|
if (iterVec->first == eventType)
|
||||||
|
{
|
||||||
|
return iterVec->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void ScriptHandlerMgr::removeObjectAllHandlers(void* object)
|
||||||
|
{
|
||||||
|
if (NULL == object || _mapObjectHandlers.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto iter = _mapObjectHandlers.find(object);
|
||||||
|
|
||||||
|
if (_mapObjectHandlers.end() != iter)
|
||||||
|
{
|
||||||
|
(iter->second).clear();
|
||||||
|
_mapObjectHandlers.erase(iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
int tolua_Cocos2d_registerScriptHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (
|
||||||
|
!tolua_isusertype(tolua_S,1,"CCNode",0,&tolua_err) ||
|
||||||
|
!toluafix_isfunction(tolua_S, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
||||||
|
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Node* node = (Node*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
||||||
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)node, handler, ScriptHandlerMgr::kNodeHandler);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolua_Cocos2d_unregisterScriptHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (
|
||||||
|
!tolua_isusertype(tolua_S,1,"CCNode",0,&tolua_err) ||
|
||||||
|
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Node* node = (Node*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)node, ScriptHandlerMgr::kNodeHandler);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolua_Cocos2d_registerScriptTapHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (
|
||||||
|
!tolua_isusertype(tolua_S,1,"CCMenuItem",0,&tolua_err) ||
|
||||||
|
!toluafix_isfunction(tolua_S, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
||||||
|
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
MenuItem* menuItem = (MenuItem*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
||||||
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)menuItem, handler, ScriptHandlerMgr::kMenuClickHandler);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolua_Cocos2d_unregisterScriptTapHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (
|
||||||
|
!tolua_isusertype(tolua_S,1,"CCMenuItem",0,&tolua_err) ||
|
||||||
|
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
MenuItem* menuItem = (MenuItem*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)menuItem, ScriptHandlerMgr::kMenuClickHandler);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolua_Cocos2d_registerScriptTouchHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (!tolua_isusertype(tolua_S,1,"CCLayer",0,&tolua_err) ||
|
||||||
|
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) ||
|
||||||
|
!tolua_isboolean(tolua_S,3,1,&tolua_err) ||
|
||||||
|
!tolua_isnumber(tolua_S,4,1,&tolua_err) ||
|
||||||
|
!tolua_isboolean(tolua_S,5,1,&tolua_err) ||
|
||||||
|
!tolua_isnoobj(tolua_S,6,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Layer* self = (Layer*) tolua_tousertype(tolua_S,1,0);
|
||||||
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
||||||
|
bool isMultiTouches = ((bool) tolua_toboolean(tolua_S,3,false));
|
||||||
|
int priority = ((int) tolua_tonumber(tolua_S,4,0));
|
||||||
|
bool swallowsTouches = ((bool) tolua_toboolean(tolua_S,5,false));
|
||||||
|
ccTouchesMode touchesMode = kTouchesAllAtOnce;
|
||||||
|
if (!isMultiTouches)
|
||||||
|
touchesMode = kTouchesOneByOne;
|
||||||
|
self->setTouchMode(touchesMode);
|
||||||
|
self->setTouchPriority(priority);
|
||||||
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::kTouchesHandler);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'registerScriptTouchHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolua_Cocos2d_unregisterScriptTouchHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (!tolua_isusertype(tolua_S,1,"CCLayer",0,&tolua_err) ||
|
||||||
|
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Layer* layer = (Layer*) tolua_tousertype(tolua_S,1,0);
|
||||||
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)layer, ScriptHandlerMgr::kTouchesHandler);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'registerScriptTouchHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolua_Cocos2d_registerScriptKeypadHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (!tolua_isusertype(tolua_S,1,"CCLayer",0,&tolua_err) ||
|
||||||
|
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) ||
|
||||||
|
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Layer* layer = (Layer*) tolua_tousertype(tolua_S,1,0);
|
||||||
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
||||||
|
|
||||||
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)layer, handler, ScriptHandlerMgr::kKeypadHandler);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'registerScriptKeypadHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolua_Cocos2d_unregisterScriptKeypadHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (!tolua_isusertype(tolua_S,1,"CCLayer",0,&tolua_err) ||
|
||||||
|
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Layer* layer = (Layer*) tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
ScriptHandlerMgr::getInstance()->removeObjectHandler(layer, ScriptHandlerMgr::kKeypadHandler);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'unregisterScriptKeypadHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolua_Cocos2d_registerScriptAccelerateHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (
|
||||||
|
!tolua_isusertype(tolua_S,1,"CCLayer",0,&tolua_err) ||
|
||||||
|
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) ||
|
||||||
|
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Layer* layer = (Layer*) tolua_tousertype(tolua_S,1,0);
|
||||||
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
||||||
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)layer, handler, ScriptHandlerMgr::kAccelerometerHandler);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'registerScriptAccelerateHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolua_Cocos2d_unregisterScriptAccelerateHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (
|
||||||
|
!tolua_isusertype(tolua_S,1,"CCLayer",0,&tolua_err) ||
|
||||||
|
!tolua_isnoobj(tolua_S,2,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Layer* layer = (Layer*) tolua_tousertype(tolua_S,1,0);
|
||||||
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)layer, ScriptHandlerMgr::kAccelerometerHandler);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'unregisterScriptAccelerateHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolua_Cocos2d_registerControlEventHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (
|
||||||
|
!tolua_isusertype(tolua_S,1,"CCControl",0,&tolua_err) ||
|
||||||
|
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) ||
|
||||||
|
!tolua_isnumber(tolua_S, 3, 0, &tolua_err)||
|
||||||
|
!tolua_isnoobj(tolua_S,4,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Control* control = (Control*) tolua_tousertype(tolua_S,1,0);
|
||||||
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
||||||
|
int controlevent = ((ControlEvent) (int) tolua_tonumber(tolua_S,3,0));
|
||||||
|
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||||
|
{
|
||||||
|
if ((controlevent & (1 << i)))
|
||||||
|
{
|
||||||
|
int handlerevent = ScriptHandlerMgr::kControlTouchDownHandler + i;
|
||||||
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)control, handler, handlerevent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'registerControlEventHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
int tolua_Cocos2d_unregisterControlEventHandler00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (
|
||||||
|
!tolua_isusertype(tolua_S,1,"CCControl",0,&tolua_err) ||
|
||||||
|
!tolua_isnumber(tolua_S, 2, 0, &tolua_err)||
|
||||||
|
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Control* control = (Control*) tolua_tousertype(tolua_S,1,0);
|
||||||
|
int handlerEvent = (int)tolua_tonumber(tolua_S,2,0);
|
||||||
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)control,handlerEvent);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'registerControlEventHandler'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tolua_reg_script_handler_mgr_type(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
tolua_usertype(tolua_S, "CCCallFunc");
|
||||||
|
tolua_usertype(tolua_S, "ScheduleHandlerDelegate");
|
||||||
|
tolua_usertype(tolua_S, "ScriptHandlerMgr");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* method: create of class LuaCallFunc */
|
||||||
|
#ifndef TOLUA_DISABLE_tolua_Cocos2d_LuaCallFunc_create00
|
||||||
|
static int tolua_Cocos2d_LuaCallFunc_create00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (
|
||||||
|
!tolua_isusertable(tolua_S,1,"CCCallFunc",0,&tolua_err) ||
|
||||||
|
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) ||
|
||||||
|
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
LUA_FUNCTION funcID = ( toluafix_ref_function(tolua_S,2,0));
|
||||||
|
{
|
||||||
|
LuaCallFunc* tolua_ret = (LuaCallFunc*) LuaCallFunc::create(funcID);
|
||||||
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||||
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCCallFunc");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
|
/* method: getInstance of class ScriptHandlerMgr */
|
||||||
|
#ifndef TOLUA_DISABLE_tolua_Cocos2d_ScriptHandlerMgr_getInstance00
|
||||||
|
static int tolua_Cocos2d_ScriptHandlerMgr_getInstance00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (!tolua_isusertable(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) ||
|
||||||
|
!tolua_isnoobj(tolua_S,2,&tolua_err) )
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
ScriptHandlerMgr* tolua_ret = (ScriptHandlerMgr*) ScriptHandlerMgr::getInstance();
|
||||||
|
tolua_pushusertype(tolua_S,(void*)tolua_ret,"ScriptHandlerMgr");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'getInstance'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
|
|
||||||
|
TOLUA_API int tolua_script_handler_mgr_open(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
tolua_open(tolua_S);
|
||||||
|
tolua_reg_script_handler_mgr_type(tolua_S);
|
||||||
|
tolua_module(tolua_S, NULL,0);
|
||||||
|
tolua_beginmodule(tolua_S, NULL);
|
||||||
|
tolua_cclass(tolua_S, "CCCallFunc", "CCCallFunc","CCActionInstant",NULL);
|
||||||
|
tolua_beginmodule(tolua_S, "CCCallFunc");
|
||||||
|
tolua_function(tolua_S, "create", tolua_Cocos2d_LuaCallFunc_create00);
|
||||||
|
tolua_endmodule(tolua_S);
|
||||||
|
tolua_cclass(tolua_S,"ScriptHandlerMgr","ScriptHandlerMgr","",NULL);
|
||||||
|
tolua_beginmodule(tolua_S, "ScriptHandlerMgr");
|
||||||
|
tolua_constant(tolua_S,"kNormalHandler",ScriptHandlerMgr::kNodeHandler);
|
||||||
|
tolua_constant(tolua_S,"kMenuClickHandler",ScriptHandlerMgr::kMenuClickHandler);
|
||||||
|
tolua_constant(tolua_S,"kNotificationHandler",ScriptHandlerMgr::kNotificationHandler);
|
||||||
|
tolua_constant(tolua_S,"kCallFuncHandler",ScriptHandlerMgr::kCallFuncHandler);
|
||||||
|
tolua_constant(tolua_S,"kScheduleHandler",ScriptHandlerMgr::kScheduleHandler);
|
||||||
|
tolua_constant(tolua_S,"kTouchesHandler",ScriptHandlerMgr::kTouchesHandler);
|
||||||
|
tolua_constant(tolua_S,"kKeypadHandler",ScriptHandlerMgr::kKeypadHandler);
|
||||||
|
tolua_constant(tolua_S,"kAccelerometerHandler",ScriptHandlerMgr::kAccelerometerHandler);
|
||||||
|
tolua_constant(tolua_S,"kControlTouchDownHandler",ScriptHandlerMgr::kControlTouchDownHandler);
|
||||||
|
tolua_constant(tolua_S,"kControlTouchDragInsideHandler",ScriptHandlerMgr::kControlTouchDragInsideHandler);
|
||||||
|
tolua_constant(tolua_S,"kControlTouchDragOutsideHandler",ScriptHandlerMgr::kControlTouchDragOutsideHandler);
|
||||||
|
tolua_constant(tolua_S,"kControlTouchDragEnterHandler",ScriptHandlerMgr::kControlTouchDragEnterHandler);
|
||||||
|
tolua_constant(tolua_S,"kControlTouchDragExitHandler",ScriptHandlerMgr::kControlTouchDragExitHandler);
|
||||||
|
tolua_constant(tolua_S,"kControlTouchUpInsideHandler",ScriptHandlerMgr::kControlTouchUpInsideHandler);
|
||||||
|
tolua_constant(tolua_S,"kControlTouchUpOutsideHandler",ScriptHandlerMgr::kControlTouchUpOutsideHandler);
|
||||||
|
tolua_constant(tolua_S,"kControlTouchCancelHandler",ScriptHandlerMgr::kControlTouchCancelHandler);
|
||||||
|
tolua_constant(tolua_S,"kControlValueChangedHandler",ScriptHandlerMgr::kControlValueChangedHandler);
|
||||||
|
tolua_function(tolua_S, "getInstance", tolua_Cocos2d_ScriptHandlerMgr_getInstance00);
|
||||||
|
tolua_endmodule(tolua_S);
|
||||||
|
tolua_endmodule(tolua_S);
|
||||||
|
return 1;
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
#ifndef __LUA_SCRIPT_HANDLER_MGR_H__
|
||||||
|
#define __LUA_SCRIPT_HANDLER_MGR_H__
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "tolua++.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "cocoa/CCObject.h"
|
||||||
|
#include "ccMacros.h"
|
||||||
|
#include "actions/CCActionInstant.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class ScheduleHandlerDelegate;
|
||||||
|
|
||||||
|
typedef int EventType;
|
||||||
|
typedef int EventHandler;
|
||||||
|
typedef std::pair<EventType, EventHandler> PairEventHandler;
|
||||||
|
typedef std::vector<PairEventHandler> VecEventHandlers;
|
||||||
|
typedef std::map<void*,VecEventHandlers> MapObjectHandlers;
|
||||||
|
typedef std::vector<ScheduleHandlerDelegate*> VecShedule;
|
||||||
|
typedef std::map<cocos2d::Node*,VecShedule> MapNodeSchedules;
|
||||||
|
|
||||||
|
class ScheduleHandlerDelegate:public cocos2d::Object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScheduleHandlerDelegate():_isUpdateSchedule(false)
|
||||||
|
{}
|
||||||
|
virtual ~ScheduleHandlerDelegate()
|
||||||
|
{}
|
||||||
|
|
||||||
|
static ScheduleHandlerDelegate* create();
|
||||||
|
|
||||||
|
void scheduleFunc(float elapse);
|
||||||
|
|
||||||
|
virtual void update(float elapse);
|
||||||
|
|
||||||
|
void setUpdateSchedule(bool isUpdateSchedule){ _isUpdateSchedule = isUpdateSchedule; }
|
||||||
|
bool isUpdateSchedule(){ return _isUpdateSchedule; }
|
||||||
|
private:
|
||||||
|
bool _isUpdateSchedule;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LuaCallFunc:public cocos2d::CallFuncN
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaCallFunc()
|
||||||
|
{}
|
||||||
|
virtual ~LuaCallFunc()
|
||||||
|
{}
|
||||||
|
|
||||||
|
static LuaCallFunc * create(int nHandler);
|
||||||
|
virtual void execute();
|
||||||
|
virtual LuaCallFunc* clone() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ScriptHandlerMgr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScriptHandlerMgr(void);
|
||||||
|
virtual ~ScriptHandlerMgr(void);
|
||||||
|
static ScriptHandlerMgr* getInstance(void);
|
||||||
|
|
||||||
|
void addObjectHandler(void* object,int handler,int eventType);
|
||||||
|
void removeObjectHandler(void* object,int eventType);
|
||||||
|
int getObjectHandler(void* object,int eventType);
|
||||||
|
void removeObjectAllHandlers(void* object);
|
||||||
|
|
||||||
|
enum HandlerEventType
|
||||||
|
{
|
||||||
|
kNodeHandler = 0,
|
||||||
|
kMenuClickHandler,
|
||||||
|
kNotificationHandler,
|
||||||
|
kCallFuncHandler,
|
||||||
|
kScheduleHandler,
|
||||||
|
kTouchesHandler,
|
||||||
|
kKeypadHandler,
|
||||||
|
kAccelerometerHandler,
|
||||||
|
|
||||||
|
kControlTouchDownHandler,
|
||||||
|
kControlTouchDragInsideHandler,
|
||||||
|
kControlTouchDragOutsideHandler,
|
||||||
|
kControlTouchDragEnterHandler,
|
||||||
|
kControlTouchDragExitHandler,
|
||||||
|
kControlTouchUpInsideHandler,
|
||||||
|
kControlTouchUpOutsideHandler,
|
||||||
|
kControlTouchCancelHandler,
|
||||||
|
kControlValueChangedHandler,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void init(void);
|
||||||
|
static ScriptHandlerMgr* _scriptHandlerMgr;
|
||||||
|
MapObjectHandlers _mapObjectHandlers;
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
TOLUA_API int tolua_Cocos2d_registerScriptHandler00(lua_State* tolua_S);
|
||||||
|
TOLUA_API int tolua_Cocos2d_unregisterScriptHandler00(lua_State* tolua_S);
|
||||||
|
|
||||||
|
TOLUA_API int tolua_Cocos2d_registerScriptTapHandler00(lua_State* tolua_S);
|
||||||
|
TOLUA_API int tolua_Cocos2d_unregisterScriptTapHandler00(lua_State* tolua_S);
|
||||||
|
|
||||||
|
TOLUA_API int tolua_Cocos2d_registerScriptTouchHandler00(lua_State* tolua_S);
|
||||||
|
TOLUA_API int tolua_Cocos2d_unregisterScriptTouchHandler00(lua_State* tolua_S);
|
||||||
|
|
||||||
|
TOLUA_API int tolua_Cocos2d_registerScriptKeypadHandler00(lua_State* tolua_S);
|
||||||
|
TOLUA_API int tolua_Cocos2d_unregisterScriptKeypadHandler00(lua_State* tolua_S);
|
||||||
|
|
||||||
|
TOLUA_API int tolua_Cocos2d_registerScriptAccelerateHandler00(lua_State* tolua_S);
|
||||||
|
TOLUA_API int tolua_Cocos2d_unregisterScriptAccelerateHandler00(lua_State* tolua_S);
|
||||||
|
|
||||||
|
TOLUA_API int tolua_Cocos2d_registerControlEventHandler00(lua_State* tolua_S);
|
||||||
|
TOLUA_API int tolua_Cocos2d_unregisterControlEventHandler00(lua_State* tolua_S);
|
||||||
|
|
||||||
|
TOLUA_API int tolua_script_handler_mgr_open(lua_State* tolua_S);
|
||||||
|
|
||||||
|
#endif //__LUA_SCRIPT_HANDLER_MGR_H__
|
|
@ -16,6 +16,7 @@ LOCAL_SRC_FILES := ../cocos2dx_support/CCLuaBridge.cpp \
|
||||||
../cocos2dx_support/Lua_web_socket.cpp \
|
../cocos2dx_support/Lua_web_socket.cpp \
|
||||||
../cocos2dx_support/LuaOpengl.cpp \
|
../cocos2dx_support/LuaOpengl.cpp \
|
||||||
../cocos2dx_support/LuaScrollView.cpp \
|
../cocos2dx_support/LuaScrollView.cpp \
|
||||||
|
../cocos2dx_support/LuaScriptHandlerMgr.cpp \
|
||||||
../tolua/tolua_event.c \
|
../tolua/tolua_event.c \
|
||||||
../tolua/tolua_is.c \
|
../tolua/tolua_is.c \
|
||||||
../tolua/tolua_map.c \
|
../tolua/tolua_map.c \
|
||||||
|
|
|
@ -48,7 +48,8 @@ SOURCES = ../lua/lapi.o \
|
||||||
../cocos2dx_support/CCBProxy.cpp \
|
../cocos2dx_support/CCBProxy.cpp \
|
||||||
../cocos2dx_support/Lua_extensions_CCB.cpp \
|
../cocos2dx_support/Lua_extensions_CCB.cpp \
|
||||||
../cocos2dx_support/LuaOpengl.cpp \
|
../cocos2dx_support/LuaOpengl.cpp \
|
||||||
../cocos2dx_support/LuaScrollView.cpp
|
../cocos2dx_support/LuaScrollView.cpp \
|
||||||
|
../cocos2dx_support/LuaScriptHandlerMgr.cpp
|
||||||
|
|
||||||
include ../../../cocos2dx/proj.emscripten/cocos2dx.mk
|
include ../../../cocos2dx/proj.emscripten/cocos2dx.mk
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,8 @@ SOURCES = ../lua/lapi.o \
|
||||||
../cocos2dx_support/CCBProxy.cpp \
|
../cocos2dx_support/CCBProxy.cpp \
|
||||||
../cocos2dx_support/Lua_extensions_CCB.cpp \
|
../cocos2dx_support/Lua_extensions_CCB.cpp \
|
||||||
../cocos2dx_support/LuaOpengl.cpp \
|
../cocos2dx_support/LuaOpengl.cpp \
|
||||||
../cocos2dx_support/LuaScrollView.cpp
|
../cocos2dx_support/LuaScrollView.cpp \
|
||||||
|
../cocos2dx_support/LuaScriptHandlerMgr.cpp
|
||||||
|
|
||||||
include ../../../cocos2dx/proj.linux/cocos2dx.mk
|
include ../../../cocos2dx/proj.linux/cocos2dx.mk
|
||||||
|
|
||||||
|
|
|
@ -42,4 +42,6 @@ files
|
||||||
"LuaOpengl.h"
|
"LuaOpengl.h"
|
||||||
"LuaScrollView.cpp"
|
"LuaScrollView.cpp"
|
||||||
"LuaScrollView.h"
|
"LuaScrollView.h"
|
||||||
|
"LuaScriptHandlerMgr.cpp"
|
||||||
|
"LuaScriptHandlerMgr.h"
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)"</Command>
|
||||||
<ClCompile Include="..\cocos2dx_support\Cocos2dxLuaLoader.cpp" />
|
<ClCompile Include="..\cocos2dx_support\Cocos2dxLuaLoader.cpp" />
|
||||||
<ClCompile Include="..\cocos2dx_support\LuaCocos2d.cpp" />
|
<ClCompile Include="..\cocos2dx_support\LuaCocos2d.cpp" />
|
||||||
<ClCompile Include="..\cocos2dx_support\LuaOpengl.cpp" />
|
<ClCompile Include="..\cocos2dx_support\LuaOpengl.cpp" />
|
||||||
|
<ClCompile Include="..\cocos2dx_support\LuaScriptHandlerMgr.cpp" />
|
||||||
<ClCompile Include="..\cocos2dx_support\LuaScrollView.cpp" />
|
<ClCompile Include="..\cocos2dx_support\LuaScrollView.cpp" />
|
||||||
<ClCompile Include="..\cocos2dx_support\Lua_extensions_CCB.cpp" />
|
<ClCompile Include="..\cocos2dx_support\Lua_extensions_CCB.cpp" />
|
||||||
<ClCompile Include="..\cocos2dx_support\Lua_web_socket.cpp" />
|
<ClCompile Include="..\cocos2dx_support\Lua_web_socket.cpp" />
|
||||||
|
@ -149,6 +150,7 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)"</Command>
|
||||||
<ClInclude Include="..\cocos2dx_support\Cocos2dxLuaLoader.h" />
|
<ClInclude Include="..\cocos2dx_support\Cocos2dxLuaLoader.h" />
|
||||||
<ClInclude Include="..\cocos2dx_support\LuaCocos2d.h" />
|
<ClInclude Include="..\cocos2dx_support\LuaCocos2d.h" />
|
||||||
<ClInclude Include="..\cocos2dx_support\LuaOpengl.h" />
|
<ClInclude Include="..\cocos2dx_support\LuaOpengl.h" />
|
||||||
|
<ClInclude Include="..\cocos2dx_support\LuaScriptHandlerMgr.h" />
|
||||||
<ClInclude Include="..\cocos2dx_support\LuaScrollView.h" />
|
<ClInclude Include="..\cocos2dx_support\LuaScrollView.h" />
|
||||||
<ClInclude Include="..\cocos2dx_support\Lua_extensions_CCB.h" />
|
<ClInclude Include="..\cocos2dx_support\Lua_extensions_CCB.h" />
|
||||||
<ClInclude Include="..\cocos2dx_support\Lua_web_socket.h" />
|
<ClInclude Include="..\cocos2dx_support\Lua_web_socket.h" />
|
||||||
|
|
|
@ -66,6 +66,9 @@
|
||||||
<ClCompile Include="..\cocos2dx_support\LuaScrollView.cpp">
|
<ClCompile Include="..\cocos2dx_support\LuaScrollView.cpp">
|
||||||
<Filter>cocos2dx_support</Filter>
|
<Filter>cocos2dx_support</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\cocos2dx_support\LuaScriptHandlerMgr.cpp">
|
||||||
|
<Filter>cocos2dx_support</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\tolua\tolua++.h">
|
<ClInclude Include="..\tolua\tolua++.h">
|
||||||
|
@ -122,5 +125,8 @@
|
||||||
<ClInclude Include="..\cocos2dx_support\LuaScrollView.h">
|
<ClInclude Include="..\cocos2dx_support\LuaScrollView.h">
|
||||||
<Filter>cocos2dx_support</Filter>
|
<Filter>cocos2dx_support</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\cocos2dx_support\LuaScriptHandlerMgr.h">
|
||||||
|
<Filter>cocos2dx_support</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -45,7 +45,7 @@ skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .
|
||||||
ParticleSystem::[getBlendFunc setBlendFunc],
|
ParticleSystem::[getBlendFunc setBlendFunc],
|
||||||
DrawNode::[getBlendFunc setBlendFunc drawPolygon],
|
DrawNode::[getBlendFunc setBlendFunc drawPolygon],
|
||||||
Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo],
|
Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo],
|
||||||
Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased unregisterScriptKeypadHandler],
|
Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased],
|
||||||
Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns],
|
Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns],
|
||||||
MenuItem.*::[create setCallback initWithCallback],
|
MenuItem.*::[create setCallback initWithCallback],
|
||||||
Copying::[*],
|
Copying::[*],
|
||||||
|
|
|
@ -295,13 +295,3 @@ class CCPlace : public CCActionInstant //<NSCopying>
|
||||||
{
|
{
|
||||||
static CCPlace* create(CCPoint pos);
|
static CCPlace* create(CCPoint pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCCallFunc : public CCActionInstant
|
|
||||||
{
|
|
||||||
static CCCallFunc* create(LUA_FUNCTION funcID);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CCCallFuncN : public CCCallFunc
|
|
||||||
{
|
|
||||||
static CCCallFuncN* create(LUA_FUNCTION funcID);
|
|
||||||
};
|
|
||||||
|
|
|
@ -59,7 +59,4 @@ class CCControl:public CCLayerRGBA
|
||||||
|
|
||||||
virtual CCPoint getTouchLocation(CCTouch* touch);
|
virtual CCPoint getTouchLocation(CCTouch* touch);
|
||||||
virtual bool isTouchInside(CCTouch * touch);
|
virtual bool isTouchInside(CCTouch * touch);
|
||||||
|
|
||||||
void addHandleOfControlEvent(LUA_FUNCTION nFunID,CCControlEvent controlEvents);
|
|
||||||
void removeHandleOfControlEvent(CCControlEvent controlEvents);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,18 +19,6 @@ class CCLayer : public CCNode
|
||||||
virtual void setTouchPriority(int priority);
|
virtual void setTouchPriority(int priority);
|
||||||
virtual int getTouchPriority() const;
|
virtual int getTouchPriority() const;
|
||||||
|
|
||||||
void registerScriptTouchHandler(LUA_FUNCTION nHandler,
|
|
||||||
bool bIsMultiTouches = false,
|
|
||||||
int nPriority = 0,
|
|
||||||
bool bSwallowsTouches = false);
|
|
||||||
void unregisterScriptTouchHandler();
|
|
||||||
|
|
||||||
void registerScriptKeypadHandler(LUA_FUNCTION nHandler);
|
|
||||||
void unregisterScriptKeypadHandler(void);
|
|
||||||
|
|
||||||
void registerScriptAccelerateHandler(LUA_FUNCTION nHandler);
|
|
||||||
void unregisterScriptAccelerateHandler(void);
|
|
||||||
|
|
||||||
static CCLayer *create(void);
|
static CCLayer *create(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,6 @@ class CCMenuItem : public CCNodeRGBA
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
bool isSelected() const;
|
bool isSelected() const;
|
||||||
|
|
||||||
void registerScriptTapHandler(LUA_FUNCTION funcID);
|
|
||||||
void unregisterScriptTapHandler(void);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCMenuItemLabel : public CCMenuItem
|
class CCMenuItemLabel : public CCMenuItem
|
||||||
|
|
|
@ -117,9 +117,6 @@ class CCNode : public CCObject
|
||||||
void scheduleUpdateWithPriorityLua(LUA_FUNCTION nHandler, int priority);
|
void scheduleUpdateWithPriorityLua(LUA_FUNCTION nHandler, int priority);
|
||||||
void unscheduleUpdate(void);
|
void unscheduleUpdate(void);
|
||||||
|
|
||||||
void registerScriptHandler(LUA_FUNCTION funcID);
|
|
||||||
void unregisterScriptHandler(void);
|
|
||||||
|
|
||||||
static CCNode * create(void);
|
static CCNode * create(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@ local CCObjectTypes = {
|
||||||
"CCImage",
|
"CCImage",
|
||||||
"CCFiniteTimeAction",
|
"CCFiniteTimeAction",
|
||||||
"CCActionInstant",
|
"CCActionInstant",
|
||||||
"CCCallFunc",
|
|
||||||
"CCCallFuncN",
|
|
||||||
"CCFlipX",
|
"CCFlipX",
|
||||||
"CCFlipY",
|
"CCFlipY",
|
||||||
"CCHide",
|
"CCHide",
|
||||||
|
|
Loading…
Reference in New Issue