Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into iss2407-class-order

This commit is contained in:
James Chen 2013-07-17 14:36:55 +08:00
commit e7452bc912
47 changed files with 1095 additions and 643 deletions

View File

@ -443,6 +443,7 @@ Developers:
Explicitly initialising CCAcceleration structure.
Add support to save/retrieve CCData into/from CCUserDefault.
Text Shadows fix
Solving 'black screen' on android.
MarcelBloemendaal
Adding secureTextEntry property to CCTextFieldTTF.
@ -454,6 +455,7 @@ Developers:
sunzhuoshi
Adding support for javascript bytecode.
Fixing bad js constant names.
ptekchand (Pranav Tekchand)
Supporting negative node scales for CCScrollView.

View File

@ -311,9 +311,8 @@ bool createAudioPlayerBySource(AudioPlayer* player)
result = (*(player->fdPlayerObject))->GetInterface(player->fdPlayerObject, getInterfaceID("SL_IID_SEEK"), &(player->fdPlayerSeek));
assert(SL_RESULT_SUCCESS == result);
// get the playback rate interface
result = (*(player->fdPlayerObject))->GetInterface(player->fdPlayerObject, getInterfaceID("SL_IID_PLAYBACKRATE"), &(player->fdPlaybackRate));
assert(SL_RESULT_SUCCESS == result);
// get the playback rate interface, if available
(*(player->fdPlayerObject))->GetInterface(player->fdPlayerObject, getInterfaceID("SL_IID_PLAYBACKRATE"), &(player->fdPlaybackRate));
return true;
}

View File

@ -1 +1 @@
08ecad70e8370c7af451fddea1c59d05e80ca696
1ab0fd6fdad74af8ce054c089d8571a05a7a04d8

View File

@ -87,7 +87,6 @@ Node::Node(void)
, _ignoreAnchorPointForPosition(false)
, _reorderChildDirty(false)
, _isTransitionFinished(false)
, _scriptHandler(0)
, _updateScriptHandler(0)
, _componentContainer(NULL)
{
@ -107,7 +106,6 @@ Node::~Node(void)
{
CCLOGINFO( "cocos2d: deallocing: %p", this );
unregisterScriptHandler();
if (_updateScriptHandler)
{
ScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(_updateScriptHandler);
@ -987,23 +985,6 @@ void Node::onExit()
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)
{
if( actionManager != _actionManager ) {

View File

@ -857,47 +857,6 @@ public:
* @return Whether or not the node is running.
*/
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.

View File

@ -47,9 +47,6 @@ Layer::Layer()
, _accelerometerEnabled(false)
, _keyboardEnabled(false)
, _keypadEnabled(false)
, _scriptTouchHandlerEntry(NULL)
, _scriptKeypadHandlerEntry(NULL)
, _scriptAccelerateHandlerEntry(NULL)
, _touchPriority(0)
, _touchMode(kTouchesAllAtOnce)
{
@ -59,9 +56,7 @@ Layer::Layer()
Layer::~Layer()
{
unregisterScriptTouchHandler();
unregisterScriptKeypadHandler();
unregisterScriptAccelerateHandler();
}
bool Layer::init()
@ -101,51 +96,20 @@ void Layer::registerWithTouchDispatcher()
{
TouchDispatcher* pDispatcher = Director::getInstance()->getTouchDispatcher();
// Using LuaBindings
if (_scriptTouchHandlerEntry)
{
if (_scriptTouchHandlerEntry->isMultiTouches())
{
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);
}
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)
{
if (kScriptTypeLua == _scriptType)
{
Set touches;
touches.addObject((Object*)pTouch);
TouchesScriptData data(nEventType,kLayerTouches,(void*)this,&touches);
TouchesScriptData data(nEventType,(void*)this,&touches);
ScriptEvent event(kTouchesEvent,&data);
return ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
@ -161,7 +125,7 @@ int Layer::excuteScriptTouchHandler(int nEventType, Set *pTouches)
{
if (kScriptTypeLua == _scriptType)
{
TouchesScriptData data(nEventType,kLayerTouches,(void*)this,pTouches);
TouchesScriptData data(nEventType,(void*)this,pTouches);
ScriptEvent event(kTouchesEvent,&data);
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
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)
{
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);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
@ -384,9 +324,9 @@ void Layer::keyBackClicked(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);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
@ -425,8 +365,6 @@ void Layer::onExit()
if( _touchEnabled )
{
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

View File

@ -83,8 +83,6 @@ public:
virtual void ccTouchesCancelled(Set *pTouches, Event *pEvent);
virtual void didAccelerate(Acceleration* pAccelerationValue);
void registerScriptAccelerateHandler(int nHandler);
void unregisterScriptAccelerateHandler(void);
/** If isTouchEnabled, this method is called onEnter. Override it to change the
way Layer receives touch events.
@ -97,11 +95,6 @@ public:
@since v0.8.0
*/
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.
You can enable / disable touch events with this property.
@ -139,18 +132,8 @@ public:
virtual bool isKeypadEnabled() const;
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 keyMenuClicked(void);
inline TouchScriptHandlerEntry* getScriptTouchHandlerEntry() const { return _scriptTouchHandlerEntry; };
inline ScriptHandlerEntry* getScriptKeypadHandlerEntry() const { return _scriptKeypadHandlerEntry; };
inline ScriptHandlerEntry* getScriptAccelerateHandlerEntry() const { return _scriptAccelerateHandlerEntry; };
//
// Overrides
//
@ -165,11 +148,6 @@ protected:
bool _keypadEnabled;
private:
// Script touch events handler
TouchScriptHandlerEntry* _scriptTouchHandlerEntry;
ScriptHandlerEntry* _scriptKeypadHandlerEntry;
ScriptHandlerEntry* _scriptAccelerateHandlerEntry;
int _touchPriority;
ccTouchesMode _touchMode;

View File

@ -91,8 +91,6 @@ bool MenuItem::initWithCallback(const ccMenuCallback& callback)
MenuItem::~MenuItem()
{
CC_SAFE_RELEASE(_target);
unregisterScriptTapHandler();
}
void MenuItem::selected()
@ -105,23 +103,6 @@ void MenuItem::unselected()
_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()
{
if (_enabled)

View File

@ -62,7 +62,6 @@ public:
MenuItem()
: _selected(false)
, _enabled(false)
, _scriptTapHandler(0)
, _callback(nullptr)
, _target(NULL)
{}
@ -86,11 +85,6 @@ public:
virtual void selected();
/** The item was 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;
//@note: It's 'setIsEnable' in cocos2d-iphone.
@ -105,7 +99,6 @@ public:
protected:
bool _selected;
bool _enabled;
int _scriptTapHandler;
// callback
ccMenuCallback _callback;
// If using the old API, the _target needs to be retained / released

View File

@ -72,7 +72,7 @@ public:
float shadowDeltaX = 0.0,
float shadowDeltaY = 0.0,
float shadowBlur = 0.0,
float shadowIntensity = 0.0,
float shadowOpacity = 0.0,
bool stroke = false,
float strokeColorR = 0.0,
float strokeColorG = 0.0,
@ -81,7 +81,7 @@ public:
{
JniMethodInfo methodInfo;
if (! JniHelper::getStaticMethodInfo(methodInfo, "org/cocos2dx/lib/Cocos2dxBitmap", "createTextBitmapShadowStroke",
"(Ljava/lang/String;Ljava/lang/String;IFFFIIIZFFFZFFFF)V"))
"(Ljava/lang/String;Ljava/lang/String;IFFFIIIZFFFFZFFFF)V"))
{
CCLOG("%s %d: error to get methodInfo", __FILE__, __LINE__);
return false;
@ -110,7 +110,7 @@ public:
jstring jstrFont = methodInfo.env->NewStringUTF(fullPathOrFontName.c_str());
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, jstrText,
jstrFont, (int)fontSize, textTintR, textTintG, textTintB, eAlignMask, nWidth, nHeight, shadow, shadowDeltaX, -shadowDeltaY, shadowBlur, stroke, strokeColorR, strokeColorG, strokeColorB, strokeSize);
jstrFont, (int)fontSize, textTintR, textTintG, textTintB, eAlignMask, nWidth, nHeight, shadow, shadowDeltaX, -shadowDeltaY, shadowBlur, shadowOpacity, stroke, strokeColorR, strokeColorG, strokeColorB, strokeSize);
methodInfo.env->DeleteLocalRef(jstrText);
methodInfo.env->DeleteLocalRef(jstrFont);

View File

@ -96,7 +96,7 @@ public class Cocos2dxBitmap {
//
createTextBitmapShadowStroke( pString, pFontName, pFontSize, 1.0f, 1.0f, 1.0f, // text font and color
pAlignment, pWidth, pHeight, // alignment and size
false, 0.0f, 0.0f, 0.0f, // no shadow
false, 0.0f, 0.0f, 0.0f, 0.0f, // no shadow
false, 1.0f, 1.0f, 1.0f, 1.0f); // no stroke
}
@ -104,7 +104,7 @@ public class Cocos2dxBitmap {
public static void createTextBitmapShadowStroke(String pString, final String pFontName, final int pFontSize,
final float fontTintR, final float fontTintG, final float fontTintB,
final int pAlignment, final int pWidth, final int pHeight, final boolean shadow,
final float shadowDX, final float shadowDY, final float shadowBlur, final boolean stroke,
final float shadowDX, final float shadowDY, final float shadowBlur, final float shadowOpacity, final boolean stroke,
final float strokeR, final float strokeG, final float strokeB, final float strokeSize) {
@ -128,7 +128,7 @@ public class Cocos2dxBitmap {
if ( shadow ) {
int shadowColor = 0x54000000;
int shadowColor = ((int)(255 * shadowOpacity) & 0xff) << 24;
paint.setShadowLayer(shadowBlur, shadowDX, shadowDY, shadowColor);
bitmapPaddingX = Math.abs(shadowDX);

View File

@ -279,12 +279,10 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig
8,
(int)(dim.width) * 4,
colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
if (!context)
{
CGColorSpaceRelease(colorSpace);
delete[] data;
break;
}
@ -319,9 +317,15 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig
CGSize offset;
offset.height = pInfo->shadowOffset.height;
offset.width = pInfo->shadowOffset.width;
CGContextSetShadow(context, offset, pInfo->shadowBlur);
CGFloat shadowColorValues[] = {0, 0, 0, pInfo->shadowOpacity};
CGColorRef shadowColor = CGColorCreate (colorSpace, shadowColorValues);
CGContextSetShadowWithColor(context, offset, pInfo->shadowBlur, shadowColor);
CGColorRelease (shadowColor);
}
CGColorSpaceRelease(colorSpace);
// normal fonts

View File

@ -166,19 +166,10 @@ enum ScriptEventType
kTouchesEvent,
kKeypadEvent,
kAccelerometerEvent,
kControlEvent,
kCommonEvent,
};
enum TouchesObjectType
{
kLayerTouches = 0,
};
enum KeypadObjectType
{
kLayerKeypad = 0,
};
struct BasicScriptData
{
//nativeobject:to get handler for lua or to get jsobject for js
@ -209,12 +200,10 @@ struct SchedulerScriptData
struct TouchesScriptData
{
int actionType;
int objectType;
void* nativeObject;
Set* touches;
TouchesScriptData(int inActionType,int inObjectType,void* inNativeObject,Set* inTouches)
TouchesScriptData(int inActionType,void* inNativeObject,Set* inTouches)
:actionType(inActionType),
objectType(inObjectType),
nativeObject(inNativeObject),
touches(inTouches)
{
@ -224,10 +213,9 @@ struct TouchesScriptData
struct KeypadScriptData
{
int actionType;
int objectType;
void* nativeObject;
KeypadScriptData(int inActionType,int inObjectType,void* inNativeObject)
:actionType(inActionType),objectType(inObjectType),nativeObject(inNativeObject)
KeypadScriptData(int inActionType,void* inNativeObject)
:actionType(inActionType),nativeObject(inNativeObject)
{
}
};
@ -285,7 +273,7 @@ public:
virtual void removeScriptHandler(int nHandler) {};
/** 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.

View File

@ -30,8 +30,10 @@ THE SOFTWARE.
NS_CC_BEGIN
class ScriptHandlerMgr;
class CC_DLL NotificationCenter : public Object
{
friend class ScriptHandlerMgr;
public:
/** NotificationCenter constructor */
NotificationCenter();

View File

@ -78,8 +78,6 @@ bool Control::init()
this->setTouchPriority(1);
// Initialise the tables
_dispatchTable = new Dictionary();
// Initialise the mapHandleOfControlEvents
_mapHandleOfControlEvent.clear();
return true;
}
@ -128,15 +126,11 @@ void Control::sendActionsForControlEvents(ControlEvent controlEvents)
invocation->invoke(this);
}
//Call ScriptFunc
if (kScriptTypeNone != _scriptType)
if (kScriptTypeLua == _scriptType)
{
int nHandler = this->getHandleOfControlEvent(controlEvents);
if (0 != nHandler)
{
cocos2d::CommonScriptData data(nHandler, "",(Object*)this);
cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
cocos2d::BasicScriptData data((void*)this,(void*)&controlEvents);
cocos2d::ScriptEvent event(cocos2d::kControlEvent,(void*)&data);
cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}
}
@ -338,30 +332,4 @@ bool Control::hasVisibleParents()
}
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

View File

@ -254,13 +254,6 @@ protected:
void removeTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
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

View File

@ -45,7 +45,7 @@
#include "physics_nodes/CCPhysicsDebugNode.h"
#include "physics_nodes/CCPhysicsSprite.h"
#endif
#include "spine/spine-cocos2dx.h"
#include "Components/CCComAttribute.h"

View File

@ -9,6 +9,7 @@
#endif
#include "LuaOpengl.h"
#include "LuaScrollView.h"
#include "LuaScriptHandlerMgr.h"
using namespace CocosDenshion;
@ -64,6 +65,7 @@ bool AppDelegate::applicationDidFinishLaunching()
#endif
tolua_opengl_open(tolua_s);
tolua_scroll_view_open(tolua_s);
tolua_script_handler_mgr_open(tolua_s);
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.push_back("cocosbuilderRes");
@ -74,8 +76,9 @@ bool AppDelegate::applicationDidFinishLaunching()
#endif
FileUtils::getInstance()->setSearchPaths(searchPaths);
pEngine->extendLuaObject();
pEngine->executeScriptFile("luaScript/controller.lua");
return true;
}

View File

@ -29,8 +29,8 @@ local function CrashTest()
ret:getParent():removeChild(ret, true)
Helper.nextAction()
end
arr:addObject(CCCallFunc:create(removeThis))
local callfunc = CCCallFunc:create(removeThis)
arr:addObject(callfunc)
--After 1.5 second, self will be removed.
ret:runAction( CCSequence:create(arr))
return ret
@ -56,7 +56,8 @@ local function LogicTest()
node:runAction(CCScaleTo:create(2, 2))
end
arr:addObject(CCCallFuncN:create(bugMe))
local callfunc = CCCallFunc:create(bugMe)
arr:addObject(callfunc)
grossini:runAction( CCSequence:create(arr));
return ret
end
@ -69,7 +70,6 @@ end
local function PauseTest()
local ret = createTestLayer("Pause Test")
local schedulerEntry = nil
local function unpause(dt)
scheduler:unscheduleScriptEntry(schedulerEntry)
@ -95,6 +95,7 @@ local function PauseTest()
pDirector:getActionManager():addAction(action, grossini, true)
schedulerEntry = scheduler:scheduleScriptFunc(unpause, 3.0, false)
elseif event == "exit" then
if schedulerEntry ~= nil then
scheduler:unscheduleScriptEntry(schedulerEntry)
@ -123,10 +124,10 @@ local function RemoveTest()
pSprite:stopActionByTag(kTagSequence)
end
local pCallback = CCCallFunc:create(stopAction)
local callfunc = CCCallFunc:create(stopAction)
local arr = CCArray:create()
arr:addObject(pMove)
arr:addObject(pCallback)
arr:addObject(callfunc)
local pSequence = CCSequence:create(arr)
pSequence:setTag(kTagSequence)

View File

@ -582,25 +582,26 @@ local function ActionSequenceCallback3(sender)
end
local function ActionSequence2()
actionSequenceLayer = CCLayer:create()
initWithLayer(actionSequenceLayer)
actionSequenceLayer = CCLayer:create()
initWithLayer(actionSequenceLayer)
alignSpritesLeft(1)
alignSpritesLeft(1)
grossini:setVisible(false)
local array = CCArray:create()
array:addObject(CCPlace:create(ccp(200,200)))
array:addObject(CCShow:create())
array:addObject(CCMoveBy:create(1, ccp(100,0)))
array:addObject(CCCallFunc:create(ActionSequenceCallback1))
array:addObject(CCCallFuncN:create(ActionSequenceCallback2))
array:addObject(CCCallFuncN:create(ActionSequenceCallback3))
local action = CCSequence:create(array)
grossini:setVisible(false)
local array = CCArray:create()
array:addObject(CCPlace:create(ccp(200,200)))
array:addObject(CCShow:create())
array:addObject(CCMoveBy:create(1, ccp(100,0)))
array:addObject(CCCallFunc:create(ActionSequenceCallback1))
array:addObject(CCCallFunc:create(ActionSequenceCallback2))
array:addObject(CCCallFunc:create(ActionSequenceCallback3))
local action = CCSequence:create(array)
grossini:runAction(action)
Helper.subtitleLabel:setString("Sequence of InstantActions")
return actionSequenceLayer
Helper.subtitleLabel:setString("Sequence of InstantActions")
return actionSequenceLayer
end
--------------------------------------
@ -703,7 +704,7 @@ local function ActionRepeatForever()
local action = CCSequence:createWithTwoActions(
CCDelayTime:create(1),
CCCallFuncN:create(repeatForever))
CCCallFunc:create(repeatForever) )
grossini:runAction(action)
@ -796,18 +797,18 @@ local function ActionCallFunc()
local action = CCSequence:createWithTwoActions(
CCMoveBy:create(2, ccp(200,0)),
CCCallFunc:create(CallFucnCallback1))
CCCallFunc:create(CallFucnCallback1) )
local array = CCArray:create()
array:addObject(CCScaleBy:create(2, 2))
array:addObject(CCFadeOut:create(2))
array:addObject(CCCallFuncN:create(CallFucnCallback2))
array:addObject(CCCallFunc:create(CallFucnCallback2))
local action2 = CCSequence:create(array)
local array2 = CCArray:create()
array2:addObject(CCRotateBy:create(3 , 360))
array2:addObject(CCFadeOut:create(2))
array2:addObject(CCCallFuncN:create(CallFucnCallback3))
array2:addObject(CCCallFunc:create(CallFucnCallback3))
local action3 = CCSequence:create(array2)
grossini:runAction(action)
@ -1087,7 +1088,7 @@ local function ActionIssue1305()
centerSprites(0)
spriteTmp = CCSprite:create("Images/grossini.png")
spriteTmp:runAction(CCCallFuncN:create(Issue1305_log))
spriteTmp:runAction(CCCallFunc:create(Issue1305_log))
Issue1305_layer:registerScriptHandler(Issue1305_onEnterOrExit)
@ -1215,15 +1216,15 @@ local function ActionIssue1327()
spr:setPosition(ccp(100, 100))
layer:addChild(spr)
local act1 = CCCallFuncN:create(logSprRotation)
local act1 = CCCallFunc:create(logSprRotation)
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 act5 = CCCallFuncN:create(logSprRotation)
local act5 = CCCallFunc:create(logSprRotation)
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 act9 = CCCallFuncN:create(logSprRotation)
local act9 = CCCallFunc:create(logSprRotation)
local array = CCArray:create()
array:addObject(act1)

View File

@ -128,7 +128,6 @@ local function runNotificationCenterTest()
local function setIsConnectToSwitch(pLight,bConnect,nIdx)
bConnectArray[nIdx] = bConnect
print("come in")
if bConnect then
CCNotificationCenter:sharedNotificationCenter():registerScriptObserver(pLight, switchStateChanged,NotificationCenterParam.MSG_SWITCH_STATE)
else
@ -372,7 +371,7 @@ local function runCCControlTest()
pDisplayValueLabel:setPosition(ccp(screenSize.width / 1.7, screenSize.height / 2.0))
pLayer:addChild(pDisplayValueLabel)
local function valueChanged(strEventName,pSender)
local function valueChanged(pSender)
if nil == pSender or nil == pDisplayValueLabel then
return
end
@ -397,7 +396,7 @@ local function runCCControlTest()
pSlider:setTag(1)
--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")
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:setTag(2)
--same with restricted
pRestrictSlider:addHandleOfControlEvent(valueChanged, CCControlEventValueChanged)
pRestrictSlider:registerControlEventHandler(valueChanged, CCControlEventValueChanged)
pLayer:addChild(pSlider)
pLayer:addChild(pRestrictSlider)
end
@ -429,7 +428,7 @@ local function runCCControlTest()
local dLayer_width = 0
--Create the colour picker,pStrEventName not use
local function colourValueChanged(pStrEventName,pSender)
local function colourValueChanged(pSender)
if nil == pSender or nil == pColorLabel then
return
end
@ -441,7 +440,7 @@ local function runCCControlTest()
local pColourPicker = CCControlColourPicker:create()
pColourPicker:setColor(Color3B(37, 46, 252))
pColourPicker:setPosition(ccp (pColourPicker:getContentSize().width / 2, 0))
pColourPicker:addHandleOfControlEvent(colourValueChanged, CCControlEventValueChanged)
pColourPicker:registerControlEventHandler(colourValueChanged, CCControlEventValueChanged)
pNode:addChild(pColourPicker)
dLayer_width = dLayer_width + pColourPicker:getContentSize().width
@ -463,7 +462,7 @@ local function runCCControlTest()
pNode:setAnchorPoint(ccp (0.5, 0.5))
--Update the color text
colourValueChanged("", pColourPicker)
colourValueChanged(pColourPicker)
end
--SwitchTest
@ -494,7 +493,7 @@ local function runCCControlTest()
pNode:addChild(pDisplayValueLabel)
--Create the switch
local function valueChanged(strEventName,pSender)
local function valueChanged(pSender)
if nil == pDisplayValueLabel or nil == pSender then
return
end
@ -516,14 +515,14 @@ local function runCCControlTest()
)
pSwitchControl:setPosition(ccp (dLayer_width + 10 + pSwitchControl:getContentSize().width / 2, 0))
pNode:addChild(pSwitchControl)
pSwitchControl:addHandleOfControlEvent(valueChanged, CCControlEventValueChanged)
pSwitchControl:registerControlEventHandler(valueChanged, CCControlEventValueChanged)
--Set the layer size
pNode:setContentSize(CCSizeMake(dLayer_width, 0))
pNode:setAnchorPoint(ccp (0.5, 0.5))
--Update the value label
valueChanged("", pSwitchControl)
valueChanged(pSwitchControl)
end
--Hvs:HelloVariableSize
@ -731,14 +730,14 @@ local function runCCControlTest()
pControlButton:setTitleColorForState(Color3B(255, 255, 255), CCControlStateHighlighted)
pControlButton:setAnchorPoint(ccp(0.5, 1))
pControlButton:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0))
pControlButton:addHandleOfControlEvent(touchDownAction,CCControlEventTouchDown)
pControlButton:addHandleOfControlEvent(touchDragInsideAction,CCControlEventTouchDragInside)
pControlButton:addHandleOfControlEvent(touchDragOutsideAction,CCControlEventTouchDragOutside)
pControlButton:addHandleOfControlEvent(touchDragEnterAction,CCControlEventTouchDragEnter)
pControlButton:addHandleOfControlEvent(touchDragExitAction,CCControlEventTouchDragExit)
pControlButton:addHandleOfControlEvent(touchUpInsideAction,CCControlEventTouchUpInside)
pControlButton:addHandleOfControlEvent(touchUpOutsideAction,CCControlEventTouchUpOutside)
pControlButton:addHandleOfControlEvent(touchCancelAction,CCControlEventTouchCancel)
pControlButton:registerControlEventHandler(touchDownAction,CCControlEventTouchDown)
pControlButton:registerControlEventHandler(touchDragInsideAction,CCControlEventTouchDragInside)
pControlButton:registerControlEventHandler(touchDragOutsideAction,CCControlEventTouchDragOutside)
pControlButton:registerControlEventHandler(touchDragEnterAction,CCControlEventTouchDragEnter)
pControlButton:registerControlEventHandler(touchDragExitAction,CCControlEventTouchDragExit)
pControlButton:registerControlEventHandler(touchUpInsideAction,CCControlEventTouchUpInside)
pControlButton:registerControlEventHandler(touchUpOutsideAction,CCControlEventTouchUpOutside)
pControlButton:registerControlEventHandler(touchCancelAction,CCControlEventTouchCancel)
pLayer:addChild(pControlButton, 1)
--Add the black background
@ -774,7 +773,7 @@ local function runCCControlTest()
pNode:addChild(pDisplayValueLabel)
-- Add the slider
local function valueChanged(strEventName,pSender)
local function valueChanged(pSender)
if nil == pSender then
return
end
@ -788,7 +787,7 @@ local function runCCControlTest()
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
pPotentiometer:addHandleOfControlEvent(valueChanged, CCControlEventValueChanged)
pPotentiometer:registerControlEventHandler(valueChanged, CCControlEventValueChanged)
pNode:addChild(pPotentiometer)
@ -799,7 +798,7 @@ local function runCCControlTest()
pNode:setAnchorPoint(ccp (0.5, 0.5))
-- Update the value label
valueChanged("", pPotentiometer)
valueChanged(pPotentiometer)
end
local function InitStepperTest(pLayer)
@ -831,7 +830,7 @@ local function runCCControlTest()
local minusSprite = CCSprite:create("extensions/stepper-minus.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
return
end
@ -842,7 +841,7 @@ local function runCCControlTest()
end
local stepper = CCControlStepper:create(minusSprite, plusSprite)
stepper:setPosition(ccp (layer_width + 10 + stepper:getContentSize().width / 2, 0))
stepper:addHandleOfControlEvent(valueChanged, CCControlEventValueChanged)
stepper:registerControlEventHandler(valueChanged, CCControlEventValueChanged)
pNode:addChild(stepper)
layer_width = layer_width + stepper:getContentSize().width
@ -852,7 +851,7 @@ local function runCCControlTest()
pNode:setAnchorPoint(ccp (0.5, 0.5))
-- Update the value label
valueChanged("", stepper)
valueChanged(stepper)
end
local function InitSpecialSceneLayer(pLayer)

View File

@ -313,7 +313,8 @@ local function shouldNotCrash(dt)
explosion:setPosition(s.width / 2, s.height / 2)
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)
end

View File

@ -377,9 +377,12 @@ local function TMXReadWriteTest()
local fadein = CCFadeIn:create(2)
local scaleback = CCScaleTo:create(1, 1)
local function removeSprite(tag, sender)
local function removeSprite(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()
if p ~= nil then
@ -388,8 +391,7 @@ local function TMXReadWriteTest()
----------cclog("atlas quantity: %d", p:textureAtlas():totalQuads())
end
local finish = CCCallFuncN:create(removeSprite)
local finish = CCCallFunc:create(removeSprite)
local arr = CCArray:create()
arr:addObject(move)
arr:addObject(rotate)

View File

@ -61,8 +61,7 @@ end
function schedule(node, callback, delay)
local delay = CCDelayTime:create(delay)
local callfunc = CCCallFunc:create(callback)
local sequence = CCSequence:createWithTwoActions(delay, callfunc)
local sequence = CCSequence:createWithTwoActions(delay, CCCallFunc:create(callback))
local action = CCRepeatForever:create(sequence)
node:runAction(action)
return action
@ -70,8 +69,7 @@ end
function performWithDelay(node, callback, delay)
local delay = CCDelayTime:create(delay)
local callfunc = CCCallFunc:create(callback)
local sequence = CCSequence:createWithTwoActions(delay, callfunc)
local sequence = CCSequence:createWithTwoActions(delay, CCCallFunc:create(callback))
node:runAction(sequence)
return sequence
end

View File

@ -45,51 +45,50 @@ local BeginPos = {x = 0, y = 0}
local _allTests = {
{ isSupported = true, name = "ActionsTest" , create_func = ActionsTest },
{ 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 = "Accelerometer" , create_func= AccelerometerMain },
{ isSupported = true, name = "ActionManagerTest" , create_func = ActionManagerTestMain },
{ isSupported = true, name = "LayerTest" , create_func = LayerTestMain },
{ isSupported = true, name = "SceneTest" , create_func = SceneTestMain },
{ isSupported = true, name = "ParallaxTest" , create_func = ParallaxTestMain },
{ 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 = true, name = "ActionsEaseTest" , create_func = EaseActionsTest },
{ isSupported = true, name = "ActionsProgressTest" , create_func = ProgressActionsTest },
{ isSupported = true, name = "ActionsTest" , create_func = ActionsTest },
{ isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain },
{ 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 = "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 = 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 = 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 = 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)

@ -1 +1 @@
Subproject commit 47d7b831bedde49e53d8daf8e619eea7932b2b79
Subproject commit 6f8b3fcb81a96054903ab7361354a288f837b1a6

View File

@ -93,17 +93,17 @@ cc.TMX_TILE_VERTICAL_FLAG = 0x40000000;
cc.TEXT_ALIGNMENT_CENTER = 0x1;
cc.TEXT_ALIGNMENT_LEFT = 0x0;
cc.TEXT_ALIGNMENT_RIGHT = 0x2;
cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x3;
cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x5;
cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0;
cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x4;
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0x9;
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0x8;
cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x2;
cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x7;
cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x1;
cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x6;
cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x0;
cc.TEXTURE_2D_PIXEL_FORMAT_A8 = 0x3;
cc.TEXTURE_2D_PIXEL_FORMAT_AI88 = 0x5;
cc.TEXTURE_2D_PIXEL_FORMAT_DEFAULT = 0x0;
cc.TEXTURE_2D_PIXEL_FORMAT_I8 = 0x4;
cc.TEXTURE_2D_PIXEL_FORMAT_PVRTC2 = 0x9;
cc.TEXTURE_2D_PIXEL_FORMAT_PVRTC4 = 0x8;
cc.TEXTURE_2D_PIXEL_FORMAT_RGB565 = 0x2;
cc.TEXTURE_2D_PIXEL_FORMAT_RGB5A1 = 0x7;
cc.TEXTURE_2D_PIXEL_FORMAT_RGB888 = 0x1;
cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444 = 0x6;
cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888 = 0x0;
cc.TOUCHES_ALL_AT_ONCE = 0x0;
cc.TOUCHES_ONE_BY_ONE = 0x1;
cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1;

View File

@ -23,6 +23,7 @@
****************************************************************************/
#include "CCBProxy.h"
#include "LuaScriptHandlerMgr.h"
CCBReader* CCBProxy::createCCBReader()
{
@ -144,7 +145,7 @@ void CCBProxy::setCallback(Node* pNode,int nHandle)
{
MenuItem *pMenuItem = dynamic_cast<MenuItem*>(pNode);
if (NULL != pMenuItem) {
pMenuItem->registerScriptTapHandler(nHandle);
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)pMenuItem, nHandle, ScriptHandlerMgr::kMenuClickHandler);
}
}
else if (NULL != dynamic_cast<ControlButton*>(pNode))
@ -152,10 +153,8 @@ void CCBProxy::setCallback(Node* pNode,int nHandle)
ControlButton *pBtnItem = dynamic_cast<ControlButton*>(pNode);
if (NULL != pBtnItem) {
//UNOD,need Btn Pros to addHanldeOfControlEvent
pBtnItem->addHandleOfControlEvent(nHandle,ControlEventTouchUpInside);
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)pBtnItem, nHandle, ScriptHandlerMgr::kControlTouchUpInsideHandler);
}
}
}

View File

@ -26,6 +26,8 @@
#include "cocos2d.h"
#include "cocoa/CCArray.h"
#include "CCScheduler.h"
#include "LuaScriptHandlerMgr.h"
#include "GUI/CCControlExtension/CCControl.h"
NS_CC_BEGIN
@ -67,6 +69,7 @@ void LuaEngine::addLuaLoader(lua_CFunction func)
void LuaEngine::removeScriptObjectByObject(Object* pObj)
{
_stack->removeScriptObjectByObject(pObj);
ScriptHandlerMgr::getInstance()->removeObjectAllHandlers(pObj);
}
void LuaEngine::removeScriptHandler(int nHandler)
@ -97,49 +100,12 @@ int LuaEngine::executeGlobalFunction(const char* functionName)
int LuaEngine::executeNodeEvent(Node* pNode, int nAction)
{
int nHandler = pNode->getScriptHandler();
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;
return 0;
}
int LuaEngine::executeMenuItemEvent(MenuItem* pMenuItem)
{
int nHandler = pMenuItem->getScriptTapHandler();
if (!nHandler) return 0;
_stack->pushInt(pMenuItem->getTag());
_stack->pushObject(pMenuItem, "CCMenuItem");
int ret = _stack->executeFunctionByHandler(nHandler, 2);
_stack->clean();
return ret;
return 0;
}
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 nHandler = pAction->getScriptHandler();
if (!nHandler) return 0;
if (pTarget)
{
_stack->pushObject(pTarget, "CCNode");
}
int ret = _stack->executeFunctionByHandler(nHandler, pTarget ? 1 : 0);
_stack->clean();
return ret;
return 0;
}
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)
{
TouchScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptTouchHandlerEntry();
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;
return 0;
}
int LuaEngine::executeLayerTouchesEvent(Layer* pLayer, int eventType, Set *pTouches)
{
TouchScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptTouchHandlerEntry();
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;
return 0;
}
int LuaEngine::executeLayerKeypadEvent(Layer* pLayer, int eventType)
{
ScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptKeypadHandlerEntry();
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;
return 0;
}
int LuaEngine::executeAccelerometerEvent(Layer* pLayer, Acceleration* pAccelerationValue)
{
ScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptAccelerateHandlerEntry();
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;
return 0;
}
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);
}
break;
case kControlEvent:
{
return handlerControlEvent(message->data);
}
break;
default:
break;
}
@ -398,9 +251,8 @@ int LuaEngine::handleNodeEvent(void* data)
if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value)
return 0;
Node* node = (Node*)(basicScriptData->nativeObject);
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::kNodeHandler);
int handler = node->getScriptHandler();
if (0 == handler)
return 0;
@ -446,7 +298,7 @@ int LuaEngine::handleMenuClickedEvent(void* data)
MenuItem* menuItem = (MenuItem*)(basicScriptData->nativeObject);
int handler = menuItem->getScriptTapHandler();
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)menuItem, ScriptHandlerMgr::kMenuClickHandler);
if (0 == handler)
return 0;
@ -487,9 +339,12 @@ int LuaEngine::handleCallFuncActionEvent(void* data)
BasicScriptData* basicScriptData = (BasicScriptData*)(data);
if (NULL == basicScriptData->nativeObject)
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);
if (NULL != target)
{
@ -523,20 +378,29 @@ int LuaEngine::handleKeypadEvent(void* data)
if (NULL == keypadScriptData->nativeObject)
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:
{
Layer* layer = (Layer*)(keypadScriptData->nativeObject);
return handleLayerKeypadEvent(layer, keypadScriptData->actionType);
}
break;
case kTypeBackClicked:
_stack->pushString("backClicked");
break;
case kTypeMenuClicked:
_stack->pushString("menuClicked");
break;
default:
break;
return 0;
}
return 0;
int ret = _stack->executeFunctionByHandler(handler, 1);
_stack->clean();
return ret;
}
int LuaEngine::handleAccelerometerEvent(void* data)
@ -548,10 +412,8 @@ int LuaEngine::handleAccelerometerEvent(void* data)
if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value)
return 0;
Layer* layer = (Layer*)(basicScriptData->nativeObject);
ScriptHandlerEntry* scriptHandlerEntry = layer->getScriptAccelerateHandlerEntry();
if (NULL == scriptHandlerEntry || 0 == scriptHandlerEntry->getHandler())
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::kAccelerometerHandler);
if (0 == handler)
return 0;
Acceleration* accelerationValue = (Acceleration*)(basicScriptData->value);
@ -559,7 +421,7 @@ int LuaEngine::handleAccelerometerEvent(void* data)
_stack->pushFloat(accelerationValue->y);
_stack->pushFloat(accelerationValue->z);
_stack->pushFloat(accelerationValue->timestamp);
int ret = _stack->executeFunctionByHandler(scriptHandlerEntry->getHandler(), 4);
int ret = _stack->executeFunctionByHandler(handler, 4);
_stack->clean();
return ret;
}
@ -599,32 +461,12 @@ int LuaEngine::handleTouchesEvent(void* data)
if (NULL == touchesScriptData->nativeObject || NULL == touchesScriptData->touches)
return 0;
switch (touchesScriptData->objectType)
{
case kLayerTouches:
{
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)
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)touchesScriptData->nativeObject, ScriptHandlerMgr::kTouchesHandler);
if (0 == handler)
return 0;
TouchScriptHandlerEntry* scriptHandlerEntry = layer->getScriptTouchHandlerEntry();
if (NULL == scriptHandlerEntry || 0 == scriptHandlerEntry->getHandler())
return 0;
switch (actionType)
switch (touchesScriptData->actionType)
{
case CCTOUCHBEGAN:
_stack->pushString("began");
@ -648,23 +490,23 @@ int LuaEngine::handleLayerTouchesEvent(Layer* layer,int actionType,Set* touches)
Director* pDirector = Director::getInstance();
lua_State *L = _stack->getLuaState();
int count = touches->count();
int count = touchesScriptData->touches->count();
int ret = 0;
if (count == 1)
{
Touch* touch = (Touch*)*(touches->begin());
Touch* touch = (Touch*)*(touchesScriptData->touches->begin());
if (NULL != touch) {
const Point pt = Director::getInstance()->convertToGL(touch->getLocationInView());
_stack->pushFloat(pt.x);
_stack->pushFloat(pt.y);
ret = _stack->executeFunctionByHandler(scriptHandlerEntry->getHandler(), 3);
ret = _stack->executeFunctionByHandler(handler, 3);
}
}
else if(count > 1)
{
lua_newtable(L);
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;
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_rawseti(L, -2, i++);
}
ret = _stack->executeFunctionByHandler(scriptHandlerEntry->getHandler(), 2);
ret = _stack->executeFunctionByHandler(handler, 2);
}
_stack->clean();
return ret;
}
int LuaEngine::handleLayerKeypadEvent(Layer* layer,int actionType)
int LuaEngine::handlerControlEvent(void* data)
{
if (NULL == layer)
if ( NULL == data )
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:
_stack->pushString("backClicked");
break;
if ((controlEvents & (1 << i)))
{
handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::kControlTouchDownHandler + i);
case kTypeMenuClicked:
_stack->pushString("menuClicked");
break;
default:
return 0;
if (0 != handler)
{
_stack->pushObject((Object*)basicScriptData->nativeObject, "CCObject");
ret = _stack->executeFunctionByHandler(handler, 1);
_stack->clean();
}
}
}
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();
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

View File

@ -119,6 +119,7 @@ public:
virtual bool handleAssert(const char *msg);
virtual int sendEvent(ScriptEvent* message);
void extendLuaObject();
private:
int handleNodeEvent(void* data);
int handleMenuClickedEvent(void* data);
@ -129,8 +130,11 @@ private:
int handleAccelerometerEvent(void* data);
int handleCommonEvent(void* data);
int handleTouchesEvent(void* data);
int handleLayerTouchesEvent(Layer* layer,int actionType,Set* touches);
int handleLayerKeypadEvent(Layer* layer,int actionType);
int handlerControlEvent(void* data);
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:
LuaEngine(void)
: _stack(NULL)

View File

@ -1 +1 @@
dcb1aae4641e4e318fc42f8d740bebe21c4277ca
ecb6191757f5eb70142d6767d49edf46074a2db4

View File

@ -1 +1 @@
d0b231fcad3b4e35d4f2a998dce1b7437ae689ab
9fac9e19f8a57d40eb90b02c0be6e9f8e20e0d22

View File

@ -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;
}

View File

@ -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__

View File

@ -16,6 +16,7 @@ LOCAL_SRC_FILES := ../cocos2dx_support/CCLuaBridge.cpp \
../cocos2dx_support/Lua_web_socket.cpp \
../cocos2dx_support/LuaOpengl.cpp \
../cocos2dx_support/LuaScrollView.cpp \
../cocos2dx_support/LuaScriptHandlerMgr.cpp \
../tolua/tolua_event.c \
../tolua/tolua_is.c \
../tolua/tolua_map.c \

View File

@ -48,7 +48,8 @@ SOURCES = ../lua/lapi.o \
../cocos2dx_support/CCBProxy.cpp \
../cocos2dx_support/Lua_extensions_CCB.cpp \
../cocos2dx_support/LuaOpengl.cpp \
../cocos2dx_support/LuaScrollView.cpp
../cocos2dx_support/LuaScrollView.cpp \
../cocos2dx_support/LuaScriptHandlerMgr.cpp
include ../../../cocos2dx/proj.emscripten/cocos2dx.mk

View File

@ -48,7 +48,8 @@ SOURCES = ../lua/lapi.o \
../cocos2dx_support/CCBProxy.cpp \
../cocos2dx_support/Lua_extensions_CCB.cpp \
../cocos2dx_support/LuaOpengl.cpp \
../cocos2dx_support/LuaScrollView.cpp
../cocos2dx_support/LuaScrollView.cpp \
../cocos2dx_support/LuaScriptHandlerMgr.cpp
include ../../../cocos2dx/proj.linux/cocos2dx.mk

View File

@ -42,4 +42,6 @@ files
"LuaOpengl.h"
"LuaScrollView.cpp"
"LuaScrollView.h"
"LuaScriptHandlerMgr.cpp"
"LuaScriptHandlerMgr.h"
}

View File

@ -130,6 +130,7 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)"</Command>
<ClCompile Include="..\cocos2dx_support\Cocos2dxLuaLoader.cpp" />
<ClCompile Include="..\cocos2dx_support\LuaCocos2d.cpp" />
<ClCompile Include="..\cocos2dx_support\LuaOpengl.cpp" />
<ClCompile Include="..\cocos2dx_support\LuaScriptHandlerMgr.cpp" />
<ClCompile Include="..\cocos2dx_support\LuaScrollView.cpp" />
<ClCompile Include="..\cocos2dx_support\Lua_extensions_CCB.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\LuaCocos2d.h" />
<ClInclude Include="..\cocos2dx_support\LuaOpengl.h" />
<ClInclude Include="..\cocos2dx_support\LuaScriptHandlerMgr.h" />
<ClInclude Include="..\cocos2dx_support\LuaScrollView.h" />
<ClInclude Include="..\cocos2dx_support\Lua_extensions_CCB.h" />
<ClInclude Include="..\cocos2dx_support\Lua_web_socket.h" />

View File

@ -66,6 +66,9 @@
<ClCompile Include="..\cocos2dx_support\LuaScrollView.cpp">
<Filter>cocos2dx_support</Filter>
</ClCompile>
<ClCompile Include="..\cocos2dx_support\LuaScriptHandlerMgr.cpp">
<Filter>cocos2dx_support</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\tolua\tolua++.h">
@ -122,5 +125,8 @@
<ClInclude Include="..\cocos2dx_support\LuaScrollView.h">
<Filter>cocos2dx_support</Filter>
</ClInclude>
<ClInclude Include="..\cocos2dx_support\LuaScriptHandlerMgr.h">
<Filter>cocos2dx_support</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -43,9 +43,9 @@ skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .
ParticleBatchNode::[getBlendFunc setBlendFunc],
LayerColor::[getBlendFunc setBlendFunc],
ParticleSystem::[getBlendFunc setBlendFunc],
DrawNode::[getBlendFunc setBlendFunc drawPolygon],
DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground],
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],
MenuItem.*::[create setCallback initWithCallback],
Copying::[*],

View File

@ -295,13 +295,3 @@ class CCPlace : public CCActionInstant //<NSCopying>
{
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);
};

View File

@ -59,7 +59,4 @@ class CCControl:public CCLayerRGBA
virtual CCPoint getTouchLocation(CCTouch* touch);
virtual bool isTouchInside(CCTouch * touch);
void addHandleOfControlEvent(LUA_FUNCTION nFunID,CCControlEvent controlEvents);
void removeHandleOfControlEvent(CCControlEvent controlEvents);
};

View File

@ -19,18 +19,6 @@ class CCLayer : public CCNode
virtual void setTouchPriority(int priority);
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);
};

View File

@ -8,9 +8,6 @@ class CCMenuItem : public CCNodeRGBA
void setEnabled(bool enabled);
bool isEnabled() const;
bool isSelected() const;
void registerScriptTapHandler(LUA_FUNCTION funcID);
void unregisterScriptTapHandler(void);
};
class CCMenuItemLabel : public CCMenuItem

View File

@ -117,9 +117,6 @@ class CCNode : public CCObject
void scheduleUpdateWithPriorityLua(LUA_FUNCTION nHandler, int priority);
void unscheduleUpdate(void);
void registerScriptHandler(LUA_FUNCTION funcID);
void unregisterScriptHandler(void);
static CCNode * create(void);
};

View File

@ -11,8 +11,6 @@ local CCObjectTypes = {
"CCImage",
"CCFiniteTimeAction",
"CCActionInstant",
"CCCallFunc",
"CCCallFuncN",
"CCFlipX",
"CCFlipY",
"CCHide",