Merge pull request #2770 from samuele3hu/test_bind_cocosbuilder

add cocosbuilder lua test sample
This commit is contained in:
minggo 2013-06-05 01:38:57 -07:00
commit 3713ff5b71
19 changed files with 427 additions and 10 deletions

View File

@ -443,7 +443,9 @@ CCObject * CCCallFunc::copyWithZone(CCZone *pZone) {
CCActionInstant::copyWithZone(pZone);
pRet->initWithTarget(m_pSelectorTarget);
pRet->m_pCallFunc = m_pCallFunc;
pRet->m_nScriptHandler = m_nScriptHandler;
if (m_nScriptHandler > 0 ) {
pRet->m_nScriptHandler = cocos2d::CCScriptEngineManager::sharedManager()->getScriptEngine()->reallocateScriptHandler(m_nScriptHandler);
}
CC_SAFE_DELETE(pNewZone);
return pRet;
}

View File

@ -174,6 +174,9 @@ public:
/** Remove script function handler, only CCLuaEngine class need to implement this function. */
virtual void removeScriptHandler(int nHandler) {};
/** Reallocate script function handler, only CCLuaEngine class need to implement this function. */
virtual int reallocateScriptHandler(int nHandler) { return -1;}
/**
@brief Execute script code contained in the given string.
@param codes holding the valid script code that should be executed.

View File

@ -558,6 +558,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) {
}
CCNodeLoader *ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className.c_str());
if (! ccNodeLoader)
{
CCLog("no corresponding node loader for %s", className.c_str());
@ -1036,6 +1037,19 @@ CCArray* CCBReader::getAnimationManagersForNodes() {
return mAnimationManagersForNodes;
}
void CCBReader::addOwnerOutletName(std::string name)
{
mOwnerOutletNames.push_back(name);
}
void CCBReader::addOwnerOutletNode(CCNode *node)
{
if (NULL != node)
return;
mOwnerOutletNodes->addObject(node);
}
/************************************************************************
Static functions
************************************************************************/

View File

@ -274,6 +274,9 @@ public:
CCNode* readFileWithCleanUp(bool bCleanUp, CCDictionary* am);
void addOwnerOutletName(std::string name);
void addOwnerOutletNode(CCNode *node);
private:
void cleanUpNodeGraph(CCNode *pNode);
bool readSequences();

View File

@ -885,6 +885,10 @@ CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CC
CC_SAFE_RETAIN(pCCBReader->mOwner);
ccbReader->mOwner = pCCBReader->mOwner;
if (NULL != ccbReader->mOwner) {
CCLOG("DDD");
}
ccbReader->getAnimationManager()->mOwner = ccbReader->mOwner;
// The assignments below are done in the CCBReader constructor.
@ -905,6 +909,36 @@ CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CC
ccbReader->getAnimationManager()->runAnimationsForSequenceIdTweenDuration(ccbReader->getAnimationManager()->getAutoPlaySequenceId(), 0);
}
if (ccbReader->isJSControlled() && pCCBReader->isJSControlled() && NULL != ccbReader->mOwner)
{
//set variables and callback to owner
//set callback
CCArray *ownerCallbackNames = ccbReader->getOwnerCallbackNames();
CCArray *ownerCallbackNodes = ccbReader->getOwnerCallbackNodes();
if (NULL != ownerCallbackNames && ownerCallbackNames->count() > 0 &&
NULL != ownerCallbackNodes && ownerCallbackNodes->count() > 0)
{
assert(ownerCallbackNames->count() == ownerCallbackNodes->count());
int nCount = ownerCallbackNames->count();
for (int i = 0 ; i < nCount; i++) {
pCCBReader->addOwnerCallbackName((dynamic_cast<CCString*>(ownerCallbackNames->objectAtIndex(i)))->getCString());
pCCBReader->addOwnerCallbackNode(dynamic_cast<CCNode*>(ownerCallbackNames->objectAtIndex(i)) );
}
}
//set variables
CCArray *ownerOutletNames = ccbReader->getOwnerOutletNames();
CCArray *ownerOutletNodes = ccbReader->getOwnerOutletNodes();
if (NULL != ownerOutletNames && ownerOutletNames->count() > 0 &&
NULL != ownerOutletNodes && ownerOutletNodes->count() > 0)
{
assert(ownerOutletNames->count() == ownerOutletNodes->count());
int nCount = ownerOutletNames->count();
for (int i = 0 ; i < nCount; i++) {
pCCBReader->addOwnerOutletName((dynamic_cast<CCString*>(ownerOutletNames->objectAtIndex(i)))->getCString());
pCCBReader->addOwnerOutletNode(dynamic_cast<CCNode*>(ownerOutletNodes->objectAtIndex(i)) );
}
}
}
return ccbFileNode;
}

View File

@ -1,3 +1,4 @@
# resources get copied from TestCpp during build, ignore them
Resources/*
!Resources/luaScript
!Resources/cocosbuilderRes

View File

@ -38,11 +38,13 @@ bool AppDelegate::applicationDidFinishLaunching()
lua_State *tolua_s = pStack->getLuaState();
tolua_extensions_ccb_open(tolua_s);
#if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY
std::vector<std::string> searchPaths;
searchPaths.push_back("cocosbuilderRes");
#if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY
searchPaths.push_back("TestCppResources");
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
#endif
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
pEngine->executeScriptFile("luaScript/controller.lua");

View File

@ -0,0 +1 @@
38e3a5fabac55b5649842cb35930af7594f093ef

View File

@ -0,0 +1 @@
13382b4a2fc6364d425aedd849893d8de79f72fb

View File

@ -0,0 +1 @@
5a60849ce6d5a81e3d62587a6651eb1a7ed7d488

View File

@ -0,0 +1 @@
2685fbcab626d939a8e2ea65b05a8a82beb90afa

View File

@ -0,0 +1,301 @@
require "CCBReaderLoad"
HelloCocosBuilderLayer = HelloCocosBuilderLayer or {}
ccb["HelloCocosBuilderLayer"] = HelloCocosBuilderLayer
HelloCocosBuilderLayerOwner = HelloCocosBuilderLayerOwner or {}
ccb["HelloCocosBuilderLayerOwner"] = HelloCocosBuilderLayerOwner
TestMenusLayer = TestMenusLayer or {}
ccb["TestMenusLayer"] = TestMenusLayer
TestMenusLayerOwner = TestMenusLayerOwner or {}
ccb["TestMenusLayerOwner"] = TestMenusLayerOwner
TestButtonsLayer = TestButtonsLayer or {}
ccb["TestButtonsLayer"] = TestButtonsLayer
TestButtonsLayerOwner = TestButtonsLayerOwner or {}
ccb["TestButtonsLayerOwner"] = TestButtonsLayerOwner
TestHeaderLayer = TestHeaderLayer or {}
ccb["TestHeaderLayer"] = TestHeaderLayer
TestHeaderLayerOwner = TestHeaderLayerOwner or {}
ccb["TestHeaderLayerOwner"] = TestHeaderLayerOwner
TestSpritesLayer = TestSpritesLayer or {}
ccb["TestSpritesLayer"] = TestSpritesLayer
TestSpritesLayerOwner = TestSpritesLayerOwner or {}
ccb["TestSpritesLayerOwner"] = TestSpritesLayerOwner
TestParticleSystemsLayer = TestParticleSystemsLayer or {}
ccb["TestParticleSystemsLayer"] = TestParticleSystemsLayer
TestParticleSystemsOwner = TestParticleSystemsOwner or {}
ccb["TestParticleSystemsLayerOwner"] = TestParticleSystemsLayerOwner
TestAnimationsLayer = TestAnimationsLayer or {}
ccb["TestAnimationsLayer"] = TestAnimationsLayer
TestAnimationsLayerOwner = TestAnimationsLayerOwner or {}
ccb["TestAnimationsLayerOwner"] = TestAnimationsLayerOwner
TestTimelineLayer = TestTimelineLayer or {}
ccb["TestTimelineLayer"] = TestTimelineLayer
TestTimelineLayerOwner = TestTimelineLayerOwner or {}
ccb["TestTimelineLayerOwner"] = TestTimelineLayerOwner
local function onMenuItemAClicked()
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"CCLabelBMFont")
if nil ~= labelBmFt then
labelBmFt:setString("Menu Item A clicked.");
end
end
end
local function onMenuItemBClicked()
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"CCLabelBMFont")
if nil ~= labelBmFt then
labelBmFt:setString("Menu Item B clicked.");
end
end
end
local function pressedC( ... )
if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then
local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"CCLabelBMFont")
if nil ~= labelBmFt then
labelBmFt:setString("Menu Item C clicked.");
end
end
end
local function onMenuTestClicked()
cclog("CCBMenuTest");
local scene = CCScene:create()
local proxy = CCBProxy:create()
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestMenus.ccbi",proxy,true,"TestMenusLayerOwner")
local layer = tolua.cast(node,"CCLayer")
if nil ~= TestMenusLayerOwner["mTestTitleLabelTTF"] then
local ccLabelTTF = tolua.cast(TestMenusLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF")
if nil ~= ccLabelTTF then
ccLabelTTF:setString("ccb/ccb/TestMenus.ccbi")
end
end
if nil ~= scene then
scene:addChild(layer)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, ccc3(0,0,0)));
end
end
TestMenusLayer["onMenuItemAClicked"] = onMenuItemAClicked
TestMenusLayer["onMenuItemBClicked"] = onMenuItemBClicked
TestMenusLayer["pressedC:"] = pressedC
local function onBackClicked()
CCDirector:sharedDirector():popScene();
end
TestHeaderLayer["onBackClicked"] = onBackClicked
local function onSpriteTestClicked()
cclog("CCBSpriteTest");
local scene = CCScene:create()
local proxy = CCBProxy:create()
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestSprites.ccbi",proxy,true,"TestSpritesLayerOwner")
local layer = tolua.cast(node,"CCLayer")
if nil ~= TestSpritesLayerOwner["mTestTitleLabelTTF"] then
local ccLabelTTF = tolua.cast(TestSpritesLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF")
if nil ~= ccLabelTTF then
ccLabelTTF:setString("ccb/ccb/TestSprites.ccbi")
end
end
if nil ~= scene then
scene:addChild(layer)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, ccc3(0,0,0)));
end
end
local function onButtonTestClicked()
cclog("CCBButtionTest");
local scene = CCScene:create()
local proxy = CCBProxy:create()
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestButtons.ccbi",proxy,true,"TestButtonsLayerOwner")
local layer = tolua.cast(node,"CCLayer")
if nil ~= TestButtonsLayerOwner["mTestTitleLabelTTF"] then
local ccLabelTTF = tolua.cast(TestButtonsLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF")
if nil ~= ccLabelTTF then
ccLabelTTF:setString("ccb/ccb/TestButtons.ccbi")
end
end
if nil ~= scene then
scene:addChild(layer)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, ccc3(0,0,0)));
end
end
local function onCCControlButtonClicked()
--print("cc")
end
TestButtonsLayer["onCCControlButtonClicked"] = onCCControlButtonClicked
local function onAnimationsTestClicked()
cclog("CCBAnimationsTestTest");
local scene = CCScene:create()
local proxy = CCBProxy:create()
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestAnimations.ccbi",proxy,true,"TestAnimationsLayerOwner")
local layer = tolua.cast(node,"CCLayer")
if nil ~= TestAnimationsLayerOwner["mTestTitleLabelTTF"] then
local ccLabelTTF = tolua.cast(TestAnimationsLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF")
if nil ~= ccLabelTTF then
ccLabelTTF:setString("ccb/ccb/TestAnimations.ccbi")
end
end
if nil ~= scene then
scene:addChild(layer)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, ccc3(0,0,0)));
end
end
local function onParticleSystemTestClicked()
cclog("CCBParticleSystemTest");
local scene = CCScene:create()
local proxy = CCBProxy:create()
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestParticleSystems.ccbi",proxy,true,"TestParticleSystemsLayer")
local layer = tolua.cast(node,"CCLayer")
if nil ~= TestParticleSystemsLayer["mTestTitleLabelTTF"] then
local ccLabelTTF = tolua.cast(TestParticleSystemsLayer["mTestTitleLabelTTF"],"CCLabelTTF")
if nil ~= ccLabelTTF then
ccLabelTTF:setString("ccb/ccb/TestParticleSystems.ccbi")
end
end
if nil ~= scene then
scene:addChild(layer)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, ccc3(0,0,0)));
end
end
local function onCCControlButtonIdleClicked()
if nil ~= TestAnimationsLayer["mAnimationManager"] then
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager")
if nil ~= animationMgr then
animationMgr:runAnimationsForSequenceNamedTweenDuration("Idle", 0.3)
end
end
end
local function onCCControlButtonWaveClicked()
if nil ~= TestAnimationsLayer["mAnimationManager"] then
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager")
if nil ~= animationMgr then
animationMgr:runAnimationsForSequenceNamedTweenDuration("Wave", 0.3)
end
end
end
local function onCCControlButtonJumpClicked()
if nil ~= TestAnimationsLayer["mAnimationManager"] then
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager")
if nil ~= animationMgr then
animationMgr:runAnimationsForSequenceNamedTweenDuration("Jump", 0.3)
end
end
end
local function onCCControlButtonFunkyClicked()
if nil ~= TestAnimationsLayer["mAnimationManager"] then
local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager")
if nil ~= animationMgr then
animationMgr:runAnimationsForSequenceNamedTweenDuration("Funky", 0.3)
end
end
end
TestAnimationsLayer["onCCControlButtonIdleClicked"] = onCCControlButtonIdleClicked
TestAnimationsLayer["onCCControlButtonWaveClicked"] = onCCControlButtonWaveClicked
TestAnimationsLayer["onCCControlButtonJumpClicked"] = onCCControlButtonJumpClicked
TestAnimationsLayer["onCCControlButtonFunkyClicked"] = onCCControlButtonFunkyClicked
local function onScrollViewTestClicked()
print("onScrollViewTestClicked")
end
local function onTimelineCallbackSoundClicked()
cclog("CCBTimelineTest");
local scene = CCScene:create()
local proxy = CCBProxy:create()
local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestTimelineCallback.ccbi",proxy,true,"TestTimelineLayerOwner")
local layer = tolua.cast(node,"CCLayer")
if nil ~= TestTimelineLayerOwner["mTestTitleLabelTTF"] then
local ccLabelTTF = tolua.cast(TestTimelineLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF")
if nil ~= ccLabelTTF then
ccLabelTTF:setString("ccb/ccb/TestTimelineCallback.ccbi")
end
end
if nil ~= scene then
scene:addChild(layer)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, ccc3(0,0,0)));
end
end
function onCallback1()
if nil ~= TestTimelineLayer["helloLabel"] then
local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"CCLabelTTF")
if nil ~= ccLabelTTF then
ccLabelTTF:runAction(CCRotateBy:create(1, 360))
ccLabelTTF:setString("Callback 1");
end
end
end
function onCallback2()
if nil ~= TestTimelineLayer["helloLabel"] then
local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"CCLabelTTF")
if nil ~= ccLabelTTF then
ccLabelTTF:runAction(CCRotateBy:create(2, 360))
ccLabelTTF:setString("Callback 2");
end
end
end
TestTimelineLayer["onCallback1"] = onCallback1
TestTimelineLayer["onCallback2"] = onCallback2
HelloCocosBuilderLayer["onMenuTestClicked"] = onMenuTestClicked
HelloCocosBuilderLayer["onSpriteTestClicked"] = onSpriteTestClicked
HelloCocosBuilderLayer["onButtonTestClicked"] = onButtonTestClicked
HelloCocosBuilderLayer["onAnimationsTestClicked"] = onAnimationsTestClicked
HelloCocosBuilderLayer["onParticleSystemTestClicked"] = onParticleSystemTestClicked
HelloCocosBuilderLayer["onScrollViewTestClicked"] = onScrollViewTestClicked
HelloCocosBuilderLayer["onTimelineCallbackSoundClicked"] = onTimelineCallbackSoundClicked
local function HelloCCBTestMainLayer()
local proxy = CCBProxy:create()
local node = CCBReaderLoad("cocosbuilderRes/ccb/HelloCocosBuilder.ccbi",proxy,true,"HelloCocosBuilderLayerOwner")
local layer = tolua.cast(node,"CCLayer")
return layer
end
function runCocosBuilder()
cclog("HelloCCBSceneTestMain")
local scene = CCScene:create()
scene:addChild(HelloCCBTestMainLayer())
scene:addChild(CreateBackMenuItem())
return scene
end

View File

@ -1,3 +1,5 @@
require "luaScript/ExtensionTest/CocosBuilderTest"
local LINE_SPACE = 40
local kItemTagBasic = 1000
@ -1008,6 +1010,7 @@ local s = CCDirector:sharedDirector():getWinSize()
local function ExtensionsMainLayer()
local function CreateExtensionsTestScene(nPerformanceNo)
print(nPerformanceNo)
local pNewscene = CreateExtensionsTestTable[nPerformanceNo]()
return pNewscene
end

View File

@ -1 +1 @@
925905c236dd9e939cbc4fea65f7177db300d593
8e637a47f18c655e82a0b57f93dc0ba49fb2e9b2

View File

@ -324,4 +324,11 @@ bool CCLuaEngine::handleAssert(const char *msg)
return ret;
}
int CCLuaEngine::reallocateScriptHandler(int nHandler)
{
int nRet = m_stack->reallocateScriptHandler(nHandler);
m_stack->clean();
return nRet;
}
NS_CC_END

View File

@ -77,6 +77,11 @@ public:
*/
virtual void removeScriptHandler(int nHandler);
/**
@brief Reallocate Lua function reference
*/
virtual int reallocateScriptHandler(int nHandler);
/**
@brief Execute script code contained in the given string.
@param codes holding the valid script code that should be executed.

View File

@ -413,4 +413,24 @@ bool CCLuaStack::handleAssert(const char *msg)
return true;
}
int CCLuaStack::reallocateScriptHandler(int nHandler)
{
LUA_FUNCTION nNewHandle = -1;
if (pushFunctionByHandler(nHandler))
{
nNewHandle = toluafix_ref_function(m_state,lua_gettop(m_state),0);
}
/*
toluafix_get_function_by_refid(m_state,nNewHandle);
if (!lua_isfunction(m_state, -1))
{
CCLOG("Error!");
}
lua_settop(m_state, 0);
*/
return nNewHandle;
}
NS_CC_END

View File

@ -71,6 +71,11 @@ public:
*/
virtual void removeScriptHandler(int nHandler);
/**
@brief Remove Lua function reference
*/
virtual int reallocateScriptHandler(int nHandler);
/**
@brief Execute script code contained in the given string.
@param codes holding the valid script code that should be executed.

View File

@ -4,13 +4,15 @@ function CCBReaderLoad(strFilePath,proxy,bSetOwner,strOwnerName)
if nil == proxy then
return
end
local strFmt = string.format("%p",proxy)
print(strFmt)
local ccbReader = proxy:createCCBReader()
local node = proxy:readCCBFromFile(strFilePath,ccbReader,bSetOwner)
local owner = ccbReader:getOwner()
local rootName = ""
--owner set in readCCBFromFile is proxy
if nil ~= owner then
print("come in owner")
--Callbacks
local ownerCallbackNames = tolua.cast(ccbReader:getOwnerCallbackNames(),"CCArray")
local ownerCallbackNodes = tolua.cast(ccbReader:getOwnerCallbackNodes(),"CCArray")
@ -26,9 +28,11 @@ function CCBReaderLoad(strFilePath,proxy,bSetOwner,strOwnerName)
--Variables
local ownerOutletNames = tolua.cast(ccbReader:getOwnerOutletNames(),"CCArray")
local ownerOutletNodes = tolua.cast(ccbReader:getOwnerOutletNodes(),"CCArray")
print(ownerOutletNames:count())
for i = 1, ownerOutletNames:count() do
local outletName = tolua.cast(ownerOutletNames:objectAtIndex(i - 1),"CCString")
local outletNode = tolua.cast(ownerOutletNodes:objectAtIndex(i - 1),"CCNode")
print(outletName:getCString())
if "" ~= strOwnerName and nil ~= ccb[strOwnerName] then
ccb[strOwnerName][outletName:getCString()] = outletNode
end
@ -37,6 +41,8 @@ function CCBReaderLoad(strFilePath,proxy,bSetOwner,strOwnerName)
local nodesWithAnimationManagers = tolua.cast(ccbReader:getNodesWithAnimationManagers(),"CCArray")
local animationManagersForNodes = tolua.cast(ccbReader:getAnimationManagersForNodes(),"CCArray")
print("Test count")
print(nodesWithAnimationManagers:count())
for i = 1 , nodesWithAnimationManagers:count() do
local innerNode = tolua.cast(nodesWithAnimationManagers:objectAtIndex(i - 1),"CCNode")
local animationManager = tolua.cast(animationManagersForNodes:objectAtIndex(i - 1),"CCBAnimationManager")
@ -44,27 +50,32 @@ function CCBReaderLoad(strFilePath,proxy,bSetOwner,strOwnerName)
if "" == documentControllerName then
end
if nil ~= ccb[documentControllerName] then
ccb[documentControllerName]["mAnimationManager"] = animationManager
end
--Callbacks
local documentCallbackNames = tolua.cast(animationManager:getDocumentCallbackNames(),"CCArray")
local documentCallbackNodes = tolua.cast(animationManager:getDocumentCallbackNodes(),"CCArray")
print(documentControllerName)
print(documentCallbackNames:count())
for i = 1,documentCallbackNames:count() do
local callbackName = tolua.cast(documentCallbackNames:objectAtIndex(i - 1),"CCString")
local callbackNode = tolua.cast(documentCallbackNodes:objectAtIndex(i - 1),"CCNode")
if "" ~= documentControllerName and nil ~= ccb[documentControllerName] then
print(callbackName:getCString())
proxy:setCallback(callbackNode,ccb[documentControllerName][callbackName:getCString()])
end
--local nHandler = _G[callbackName:getCString()]
--proxy:setCallback(callbackNode,nHandler)
--callbackNode.setCallback(controller[callbackName], controller);
end
--Variables
local documentOutletNames = tolua.cast(animationManager:getDocumentOutletNames(),"CCArray")
local documentOutletNodes = tolua.cast(animationManager:getDocumentOutletNodes(),"CCArray")
print(documentOutletNames:count())
for i = 1, documentOutletNames:count() do
local outletName = tolua.cast(documentOutletNames:objectAtIndex(i - 1),"CCString")
local outletNode = tolua.cast(documentOutletNodes:objectAtIndex(i - 1),"CCNode")
print(outletName:getCString())
if nil ~= ccb[documentControllerName] then
ccb[documentControllerName][outletName:getCString()] = outletNode
end
@ -75,12 +86,14 @@ function CCBReaderLoad(strFilePath,proxy,bSetOwner,strOwnerName)
]]--
--Setup timeline callbacks
local keyframeCallbacks = animationManager:getKeyframeCallbacks()
print(keyframeCallbacks:count())
for i = 1 , keyframeCallbacks:count() do
local callbackCombine = tolua.cast(keyframeCallbacks:objectAtIndex(i - 1),"CCString"):getCString()
local beignIndex,endIndex = string.find(callbackCombine,":")
local callbackType = tonumber(string.sub(callbackCombine,1,beignIndex - 1))
local callbackName = string.sub(callbackCombine,endIndex + 1, -1)
--Document callback
print(callbackName)
if 1 == callbackType and nil ~= ccb[documentControllerName] then
local callfunc = CCCallFunc:create(ccb[documentControllerName][callbackName])
animationManager:setCallFuncForLuaCallbackNamed(callfunc, callbackCombine);