mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7022 from samuele3hu/v3_fix
Add bytecode and encrypted files test cases for Lua
This commit is contained in:
commit
af88cf053b
|
@ -47,9 +47,11 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// register lua engine
|
||||
LuaEngine* pEngine = LuaEngine::getInstance();
|
||||
ScriptEngineManager::getInstance()->setScriptEngine(pEngine);
|
||||
|
||||
LuaStack* stack = pEngine->getLuaStack();
|
||||
stack->setXXTEAKeyAndSign("2dxLua", strlen("2dxLua"), "XXTEA", strlen("XXTEA"));
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID ||CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
LuaStack* stack = pEngine->getLuaStack();
|
||||
register_assetsmanager_test_sample(stack->getLuaState());
|
||||
#endif
|
||||
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,104 @@
|
|||
require("src/ByteCodeEncryptTest/ByteCodeTest")
|
||||
require("src/ByteCodeEncryptTest/ByteCodeAndEncryptTest")
|
||||
|
||||
local LINE_SPACE = 40
|
||||
local ItemTagBasic = 1000
|
||||
|
||||
local ByteCodeEncryptEnum =
|
||||
{
|
||||
TEST_BYTECODE = 0,
|
||||
TEST_BYTECODE_ENCRYPT = 1,
|
||||
TEST_MAX_COUNT = 2,
|
||||
}
|
||||
|
||||
local TestsName =
|
||||
{
|
||||
"ByteCodeFileTest",
|
||||
"ByteCodeAndEncryptFileTest",
|
||||
}
|
||||
|
||||
local CreateByteCodeEncryptTestTable =
|
||||
{
|
||||
runByteCodeFileTest,
|
||||
runByteCodeAndEncryptFileTest,
|
||||
}
|
||||
|
||||
local function byteCodeEncryptMainLayer()
|
||||
local size = cc.Director:getInstance():getWinSize()
|
||||
|
||||
local function createByteCodeEncryptTestScene(index)
|
||||
local newScene = CreateByteCodeEncryptTestTable[index]()
|
||||
return newScene
|
||||
end
|
||||
|
||||
local function menuCallback(tag, sender)
|
||||
local scene = nil
|
||||
local index = sender:getLocalZOrder() - ItemTagBasic
|
||||
local byteCodeEncryptScene = createByteCodeEncryptTestScene(index)
|
||||
if nil ~= byteCodeEncryptScene then
|
||||
cc.Director:getInstance():replaceScene(byteCodeEncryptScene)
|
||||
end
|
||||
end
|
||||
|
||||
local layer = cc.Layer:create()
|
||||
local menu = cc.Menu:create()
|
||||
menu:setPosition(cc.p(0, 0))
|
||||
cc.MenuItemFont:setFontName("Arial")
|
||||
cc.MenuItemFont:setFontSize(24)
|
||||
|
||||
for i = 1, ByteCodeEncryptEnum.TEST_MAX_COUNT do
|
||||
local item = cc.MenuItemFont:create(TestsName[i])
|
||||
item:registerScriptTapHandler(menuCallback)
|
||||
item:setPosition(size.width / 2, size.height - i * LINE_SPACE)
|
||||
menu:addChild(item, ItemTagBasic + i)
|
||||
end
|
||||
|
||||
layer:addChild(menu)
|
||||
|
||||
-- handling touch events
|
||||
local beginPos = {x = 0, y = 0}
|
||||
local function onTouchesBegan(touches, event)
|
||||
beginPos = touches[1]:getLocation()
|
||||
end
|
||||
|
||||
local function onTouchesMoved(touches, event)
|
||||
local location = touches[1]:getLocation()
|
||||
|
||||
local nMoveY = location.y - beginPos.y
|
||||
local curPosx, curPosy = menu:getPosition()
|
||||
local nextPosy = curPosy + nMoveY
|
||||
local winSize = cc.Director:getInstance():getWinSize()
|
||||
if nextPosy < 0 then
|
||||
menu:setPosition(0, 0)
|
||||
return
|
||||
end
|
||||
|
||||
if nextPosy > ((ByteCodeEncryptEnum.TEST_MAX_COUNT + 1) * LINE_SPACE - winSize.height) then
|
||||
menu:setPosition(0, ((ByteCodeEncryptEnum.TEST_MAX_COUNT + 1) * LINE_SPACE - winSize.height))
|
||||
return
|
||||
end
|
||||
|
||||
menu:setPosition(curPosx, nextPosy)
|
||||
beginPos = {x = location.x, y = location.y}
|
||||
end
|
||||
|
||||
local listener = cc.EventListenerTouchAllAtOnce:create()
|
||||
listener:registerScriptHandler(onTouchesBegan,cc.Handler.EVENT_TOUCHES_BEGAN )
|
||||
listener:registerScriptHandler(onTouchesMoved,cc.Handler.EVENT_TOUCH_MOVED )
|
||||
|
||||
local eventDispatcher = layer:getEventDispatcher()
|
||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layer)
|
||||
|
||||
return layer
|
||||
end
|
||||
-------------------------------------
|
||||
-- ByteCodeEncrypt Test
|
||||
-------------------------------------
|
||||
function ByteCodeEncryptTestMain()
|
||||
local scene = cc.Scene:create()
|
||||
|
||||
scene:addChild(byteCodeEncryptMainLayer())
|
||||
scene:addChild(CreateBackMenuItem())
|
||||
|
||||
return scene
|
||||
end
|
Binary file not shown.
|
@ -15,6 +15,7 @@ require "src/ActionsProgressTest/ActionsProgressTest"
|
|||
require "src/ActionsTest/ActionsTest"
|
||||
require "src/AssetsManagerTest/AssetsManagerTest"
|
||||
require "src/BugsTest/BugsTest"
|
||||
require "src/ByteCodeEncryptTest/ByteCodeEncryptTest"
|
||||
require "src/ClickAndMoveTest/ClickAndMoveTest"
|
||||
require "src/CocosDenshionTest/CocosDenshionTest"
|
||||
require "src/CocoStudioTest/CocoStudioTest"
|
||||
|
@ -70,6 +71,7 @@ local _allTests = {
|
|||
{ isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain },
|
||||
{ isSupported = false, name = "Box2dTestBed" , create_func= Box2dTestBedMain },
|
||||
{ isSupported = true, name = "BugsTest" , create_func= BugsTestMain },
|
||||
{ isSupported = true, name = "ByteCodeEncryptTest" , create_func= ByteCodeEncryptTestMain },
|
||||
{ isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain },
|
||||
{ isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest },
|
||||
{ isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain },
|
||||
|
|
Loading…
Reference in New Issue