mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1305 from dualface/gles20
fixed #1477: Updated TestLua.
This commit is contained in:
commit
ef059a8db5
|
@ -38,7 +38,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
pDirector->setAnimationInterval(1.0 / 60);
|
||||
|
||||
// register lua engine
|
||||
CCLuaEngine* pEngine = CCLuaEngine::create();
|
||||
CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
|
||||
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
|
|
@ -33,7 +33,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
pDirector->setAnimationInterval(1.0 / 60);
|
||||
|
||||
// register lua engine
|
||||
CCScriptEngineProtocol* pEngine = CCLuaEngine::engine();
|
||||
CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
|
||||
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
|
||||
|
||||
std::string dirPath = "luaScript";
|
||||
|
|
|
@ -85,9 +85,9 @@ local function getBaseLayer()
|
|||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
item1:registerScriptHandler(backCallback)
|
||||
item2:registerScriptHandler(restartCallback)
|
||||
item3:registerScriptHandler(nextCallback)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
|
||||
local menu = CCMenu:create()
|
||||
menu:addChild(item1)
|
||||
|
|
|
@ -61,9 +61,9 @@ local function initWithLayer(layer)
|
|||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
item1:registerScriptHandler(backCallback)
|
||||
item2:registerScriptHandler(restartCallback)
|
||||
item3:registerScriptHandler(nextCallback)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
|
||||
local menu = CCMenu:create()
|
||||
menu:addChild(item1)
|
||||
|
|
|
@ -79,9 +79,9 @@ local function initWithLayer(layer)
|
|||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
item1:registerScriptHandler(backCallback)
|
||||
item2:registerScriptHandler(restartCallback)
|
||||
item3:registerScriptHandler(nextCallback)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
item1:setPosition(ccp(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
||||
item2:setPosition(ccp(size.width / 2, item2:getContentSize().height / 2))
|
||||
item3:setPosition(ccp(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
||||
|
|
|
@ -392,9 +392,9 @@ function CreateEffectsTestLayer()
|
|||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
item1:registerScriptHandler(backCallback)
|
||||
item2:registerScriptHandler(restartCallback)
|
||||
item3:registerScriptHandler(nextCallback)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
|
||||
local menu = CCMenu:create()
|
||||
menu:addChild(item1)
|
||||
|
|
|
@ -81,9 +81,9 @@ local function getBaseLayer()
|
|||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
item1:registerScriptHandler(backCallback)
|
||||
item2:registerScriptHandler(restartCallback)
|
||||
item3:registerScriptHandler(nextCallback)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
|
||||
local menu = CCMenu:create()
|
||||
menu:addChild(item1)
|
||||
|
@ -98,7 +98,7 @@ local function getBaseLayer()
|
|||
|
||||
local itemMode = CCMenuItemToggle:create(CCMenuItemFont:create("Use High Quality Mode"))
|
||||
itemMode:addSubItem(CCMenuItemFont:create("Use Fast Mode"))
|
||||
itemMode:registerScriptHandler(modeCallback)
|
||||
itemMode:registerScriptTapHandler(modeCallback)
|
||||
local menuMode = CCMenu:create()
|
||||
menuMode:addChild(itemMode)
|
||||
menuMode:setPosition(ccp(s.width / 2, s.height / 4))
|
||||
|
|
|
@ -73,9 +73,9 @@ local function getBaseLayer()
|
|||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
item1:registerScriptHandler(backCallback)
|
||||
item2:registerScriptHandler(restartCallback)
|
||||
item3:registerScriptHandler(nextCallback)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
|
||||
local menu = CCMenu:create()
|
||||
menu:addChild(item1)
|
||||
|
|
|
@ -113,10 +113,10 @@ local function getBaseLayer()
|
|||
local item4 = CCMenuItemToggle:create(CCMenuItemFont:create("Free Movement"))
|
||||
item4:addSubItem(CCMenuItemFont:create("Relative Movement"))
|
||||
item4:addSubItem(CCMenuItemFont:create("Grouped Movement"))
|
||||
item1:registerScriptHandler(backCallback)
|
||||
item2:registerScriptHandler(restartCallback)
|
||||
item3:registerScriptHandler(nextCallback)
|
||||
item4:registerScriptHandler(toggleCallback)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
item4:registerScriptTapHandler(toggleCallback)
|
||||
|
||||
local menu = CCMenu:create()
|
||||
menu:addChild(item1)
|
||||
|
|
|
@ -247,7 +247,7 @@ local function initWithLayer(layer, controlMenuVisible)
|
|||
CCMenuItemFont:setFontName("Arial")
|
||||
CCMenuItemFont:setFontSize(24)
|
||||
local mainItem = CCMenuItemFont:create("Back")
|
||||
mainItem:registerScriptHandler(toPerformanceMainLayer)
|
||||
mainItem:registerScriptTapHandler(toPerformanceMainLayer)
|
||||
mainItem:setPosition(s.width - 50, 25)
|
||||
local menu = CCMenu:create()
|
||||
menu:addChild(mainItem)
|
||||
|
@ -257,9 +257,9 @@ local function initWithLayer(layer, controlMenuVisible)
|
|||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
item1:registerScriptHandler(backCallback)
|
||||
item2:registerScriptHandler(restartCallback)
|
||||
item3:registerScriptHandler(nextCallback)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
item1:setPosition(s.width / 2 - 100, 30)
|
||||
item2:setPosition(s.width / 2, 30)
|
||||
item3:setPosition(s.width / 2 + 100, 30)
|
||||
|
@ -344,10 +344,10 @@ local function initWithMainTest(scene, asubtest, nNodes)
|
|||
|
||||
CCMenuItemFont:setFontSize(65)
|
||||
local decrease = CCMenuItemFont:create(" - ")
|
||||
decrease:registerScriptHandler(onDecrease)
|
||||
decrease:registerScriptTapHandler(onDecrease)
|
||||
decrease:setColor(ccc3(0, 200, 20))
|
||||
local increase = CCMenuItemFont:create(" + ")
|
||||
increase:registerScriptHandler(onIncrease)
|
||||
increase:registerScriptTapHandler(onIncrease)
|
||||
increase:setColor(ccc3(0, 200, 20))
|
||||
|
||||
local menu = CCMenu:create()
|
||||
|
@ -370,7 +370,7 @@ local function initWithMainTest(scene, asubtest, nNodes)
|
|||
for i = 1, 9 do
|
||||
local str = i .. " "
|
||||
local itemFont = CCMenuItemFont:create(str)
|
||||
itemFont:registerScriptHandler(testNCallback)
|
||||
itemFont:registerScriptTapHandler(testNCallback)
|
||||
--itemFont:setTag(i)
|
||||
subMenu:addChild(itemFont, kBasicZOrder + i, kBasicZOrder + i)
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ local function PerformanceMainLayer()
|
|||
CCMenuItemFont:setFontSize(24)
|
||||
for i = 0, MAX_COUNT - 1 do
|
||||
local item = CCMenuItemFont:create(testsName[i])
|
||||
item:registerScriptHandler(menuCallback)
|
||||
item:registerScriptTapHandler(menuCallback)
|
||||
item:setPosition(s.width / 2, s.height - (i + 1) * LINE_SPACE)
|
||||
menu:addChild(item, kItemTagBasic + i, kItemTagBasic + i)
|
||||
end
|
||||
|
|
|
@ -76,9 +76,9 @@ local function createLayer1()
|
|||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
item1:registerScriptHandler(backCallback)
|
||||
item2:registerScriptHandler(restartCallback)
|
||||
item3:registerScriptHandler(nextCallback)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
|
||||
local menu = CCMenu:create()
|
||||
menu:addChild(item1)
|
||||
|
@ -119,9 +119,9 @@ local function createLayer2()
|
|||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
item1:registerScriptHandler(backCallback)
|
||||
item2:registerScriptHandler(restartCallback)
|
||||
item3:registerScriptHandler(nextCallback)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
|
||||
local menu = CCMenu:create()
|
||||
menu:addChild(item1)
|
||||
|
|
|
@ -25,7 +25,7 @@ end
|
|||
function CreateBackMenuItem()
|
||||
local label = CCLabelTTF:create("MainMenu", "Arial", 20)
|
||||
local MenuItem = CCMenuItemLabel:create(label)
|
||||
MenuItem:registerScriptHandler(MainMenuCallback)
|
||||
MenuItem:registerScriptTapHandler(MainMenuCallback)
|
||||
|
||||
local s = CCDirector:sharedDirector():getWinSize()
|
||||
local Menu = CCMenu:create()
|
||||
|
|
|
@ -131,6 +131,7 @@ function CreateTestMenu()
|
|||
end
|
||||
|
||||
local function menuCallback(tag)
|
||||
print(tag)
|
||||
local Idx = tag - 10000
|
||||
local testScene = CreateTestScene(Idx)
|
||||
if testScene then
|
||||
|
@ -141,7 +142,7 @@ function CreateTestMenu()
|
|||
-- add close menu
|
||||
local s = CCDirector:sharedDirector():getWinSize()
|
||||
local CloseItem = CCMenuItemImage:create(s_pPathClose, s_pPathClose)
|
||||
CloseItem:registerScriptHandler(closeCallback)
|
||||
CloseItem:registerScriptTapHandler(closeCallback)
|
||||
CloseItem:setPosition(ccp(s.width - 30, s.height - 30))
|
||||
|
||||
local CloseMenu = CCMenu:create()
|
||||
|
@ -155,7 +156,7 @@ function CreateTestMenu()
|
|||
local testLabel = CCLabelTTF:create(labelName, "Arial", 24)
|
||||
local testMenuItem = CCMenuItemLabel:create(testLabel)
|
||||
|
||||
testMenuItem:registerScriptHandler(menuCallback)
|
||||
testMenuItem:registerScriptTapHandler(menuCallback)
|
||||
testMenuItem:setPosition(ccp(s.width / 2, (s.height - (index + 1) * LINE_SPACE)))
|
||||
MainMenu:addChild(testMenuItem, index + 10000, index + 10000)
|
||||
end
|
||||
|
|
|
@ -307,14 +307,14 @@ int CCLuaEngine::executeNodeEvent(CCNode* pNode, int nAction)
|
|||
if (nAction == kCCNodeOnEnter)
|
||||
{
|
||||
dict["name"] = CCLuaValue::stringValue("enter");
|
||||
this->pushCCLuaValueDict(dict);
|
||||
ret = this->executeFunctionByHandler(nScriptHandler, 1);
|
||||
pushCCLuaValueDict(dict);
|
||||
ret = executeFunctionByHandler(nScriptHandler, 1);
|
||||
}
|
||||
else if (nAction == kCCNodeOnExit)
|
||||
{
|
||||
dict["name"] = CCLuaValue::stringValue("exit");
|
||||
this->pushCCLuaValueDict(dict);
|
||||
ret = this->executeFunctionByHandler(nScriptHandler, 1);
|
||||
pushCCLuaValueDict(dict);
|
||||
ret = executeFunctionByHandler(nScriptHandler, 1);
|
||||
}
|
||||
} while (0);
|
||||
return ret;
|
||||
|
@ -327,8 +327,8 @@ int CCLuaEngine::executeMenuItemEvent(CCMenuItem* pMenuItem)
|
|||
{
|
||||
int nScriptHandler = pMenuItem->getScriptTapHandler();
|
||||
CC_BREAK_IF(0 == nScriptHandler);
|
||||
ret = this->pushInt(pMenuItem->getTag());
|
||||
ret = this->executeFunctionByHandler(nScriptHandler, 1);
|
||||
ret = pushInt(pMenuItem->getTag());
|
||||
ret = executeFunctionByHandler(nScriptHandler, 1);
|
||||
} while (0);
|
||||
return ret;
|
||||
}
|
||||
|
@ -340,8 +340,8 @@ int CCLuaEngine::executeNotificationEvent(CCNotificationCenter* pNotificationCen
|
|||
{
|
||||
int nScriptHandler = pNotificationCenter->getScriptHandler();
|
||||
CC_BREAK_IF(0 == nScriptHandler);
|
||||
ret = this->pushString(pszName);
|
||||
ret = this->executeFunctionByHandler(nScriptHandler, 1);
|
||||
ret = pushString(pszName);
|
||||
ret = executeFunctionByHandler(nScriptHandler, 1);
|
||||
} while (0);
|
||||
return ret;
|
||||
}
|
||||
|
@ -355,9 +355,9 @@ int CCLuaEngine::executeCallFuncActionEvent(CCCallFunc* pAction, CCObject* pTarg
|
|||
CC_BREAK_IF(0 == nScriptHandler);
|
||||
if (pTarget != NULL)
|
||||
{
|
||||
ret = this->pushCCObject(pTarget, "CCNode");
|
||||
ret = pushCCObject(pTarget, "CCNode");
|
||||
}
|
||||
ret = this->executeFunctionByHandler(nScriptHandler, 1);
|
||||
ret = executeFunctionByHandler(nScriptHandler, 1);
|
||||
} while (0);
|
||||
return ret;
|
||||
}
|
||||
|
@ -369,8 +369,8 @@ int CCLuaEngine::executeSchedule(CCTimer* pTimer, float dt, CCNode* pNode/* = NU
|
|||
{
|
||||
int nScriptHandler = pTimer->getScriptHandler();
|
||||
CC_BREAK_IF(0 == nScriptHandler);
|
||||
ret = this->pushFloat(dt);
|
||||
ret = this->executeFunctionByHandler(nScriptHandler, 1);
|
||||
ret = pushFloat(dt);
|
||||
ret = executeFunctionByHandler(nScriptHandler, 1);
|
||||
} while (0);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue