issue #2244:Modify CallFunc event bug and modify a function name to createCCBreader

This commit is contained in:
samuele3hu 2013-07-04 17:54:02 +08:00
parent 570f2663f4
commit b0e4757c24
7 changed files with 21 additions and 14 deletions

View File

@ -511,6 +511,10 @@ CallFunc * CallFunc::clone() const
}
else if( _function )
a->initWithFunction(_function);
else if (_scriptHandler > 0 ) {
a->_scriptHandler = cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->reallocateScriptHandler(_scriptHandler);
}
a->autorelease();
return a;
@ -561,7 +565,7 @@ void CallFunc::execute() {
} else if( _function )
_function();
if (0 != _scriptHandler) {
BasicScriptData data((void*)&_scriptHandler);
BasicScriptData data((void*)this);
ScriptEvent event(kCallFuncEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
@ -621,8 +625,11 @@ void CallFuncN::execute() {
else if (_functionN) {
_functionN(_target);
}
if (_scriptHandler) {
ScriptEngineManager::sharedManager()->getScriptEngine()->executeCallFuncActionEvent(this, _target);
if (0 != _scriptHandler)
{
BasicScriptData data((void*)this,(void*)_target);
ScriptEvent event(kCallFuncEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}

View File

@ -549,7 +549,7 @@ void Node::cleanup()
ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&scriptEvent);
}
else if(_scriptType != kScriptTypeJavascript)
else if(_scriptType == kScriptTypeJavascript)
{
ScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kNodeOnCleanup);
}

View File

@ -601,7 +601,7 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann
if(jsControlled) {
String* callbackName = String::createWithFormat("%d:%s", selectorTarget, selectorName.c_str());
CallFunc *callback = (CallFunc*)(mKeyframeCallFuncs->objectForKey(callbackName->getCString()))->copy()->autorelease();
CallFunc *callback = ((CallFunc*)(mKeyframeCallFuncs->objectForKey(callbackName->getCString())))->clone();
if(callback != NULL) {
actions->addObject(callback);

View File

@ -24,7 +24,7 @@
#include "CCBProxy.h"
CCBReader* CCBProxy::createBreader()
CCBReader* CCBProxy::createCCBreader()
{
NodeLoaderLibrary *ccNodeLoaderLibrary = NodeLoaderLibrary::sharedNodeLoaderLibrary();

View File

@ -14,7 +14,7 @@ public:
CCBProxy() { }
virtual ~ CCBProxy(){ }
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBProxy, create);
CCBReader* createBreader();
CCBReader* createCCBreader();
Node* readCCBFromFile(const char *pszFileName,CCBReader* pCCBReader,bool bSetOwner = false);
const char* getNodeTypeName(Node* pNode);
void setCallback(Node* pNode,int nHandle);

View File

@ -485,7 +485,7 @@ int LuaEngine::handleCallFuncActionEvent(void* data)
return 0;
BasicScriptData* basicScriptData = (BasicScriptData*)(data);
if (NULL == basicScriptData->nativeObject ||NULL == basicScriptData->value)
if (NULL == basicScriptData->nativeObject)
return 0;
CallFunc* callFunc = (CallFunc*)(basicScriptData->nativeObject);

View File

@ -1902,8 +1902,8 @@ tolua_lerror:
#endif //#ifndef TOLUA_DISABLE
/* method: getOwnerCallbackNodes of class CCBReader */
#ifndef TOLUA_DISABLE_tolua_Cocos2d_CCBProxy_createBreader00
static int tolua_Cocos2d_CCBProxy_createBreader00(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_Cocos2d_CCBProxy_createCCBreader00
static int tolua_Cocos2d_CCBProxy_createCCBreader00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@ -1917,10 +1917,10 @@ static int tolua_Cocos2d_CCBProxy_createBreader00(lua_State* tolua_S)
{
CCBProxy* self = (CCBProxy*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'CreateBreader'", NULL);
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createCCBreader'", NULL);
#endif
{
CCBReader* tolua_ret = (CCBReader*) self->createBreader();
CCBReader* tolua_ret = (CCBReader*) self->createCCBreader();
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,"CCBReader");
@ -1929,7 +1929,7 @@ static int tolua_Cocos2d_CCBProxy_createBreader00(lua_State* tolua_S)
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'CreateBreader'.",&tolua_err);
tolua_error(tolua_S,"#ferror in function 'createCCBreader'.",&tolua_err);
return 0;
#endif
}
@ -2133,7 +2133,7 @@ TOLUA_API int tolua_extensions_ccb_open(lua_State* tolua_S){
tolua_function(tolua_S,".call",tolua_Cocos2d_CCBProxy_new00_local);
tolua_function(tolua_S,"delete",tolua_Cocos2d_CCBProxy_delete00);
tolua_function(tolua_S, "create", tolua_Cocos2d_CCBProxy_create00);
tolua_function(tolua_S, "createCCBReader", tolua_Cocos2d_CCBProxy_createBreader00);
tolua_function(tolua_S, "createCCBReader", tolua_Cocos2d_CCBProxy_createCCBreader00);
tolua_function(tolua_S, "readCCBFromFile", tolua_Cocos2d_CCBProxy_readCCBFromFile00);
tolua_function(tolua_S, "getNodeTypeName", tolua_Cocos2d_CCBProxy_getNodeTypeName00);
tolua_function(tolua_S, "setCallback", tolua_Cocos2d_CCBProxy_setCallback00);