Delete SceneEditorTest from ExtensionTest and add related binary loading to CocoStudioSceneTest

This commit is contained in:
samuele3hu 2014-07-15 11:34:24 +08:00
parent b3bfa87f51
commit 3ab7520667
3 changed files with 210 additions and 309 deletions

View File

@ -25,6 +25,15 @@ SceneEditorTestLayer.title =
"Trigger Test",
}
SceneEditorTestLayer.loadtypeStr=
{
"change to load \nwith binary file",
"change to load \nwith json file"
}
SceneEditorTestLayer.fileName = ""
SceneEditorTestLayer.rootNode = nil
function SceneEditorTestLayer.extend(target)
local t = tolua.getpeer(target)
if not t then
@ -70,9 +79,44 @@ function SceneEditorTestLayer:createTitle()
title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30))
end
function SceneEditorTestLayer:loadFileChangeHelper(filePathName)
local indexTable = {}
local index = 0
while true do
index = string.find(filePathName, "%.", index + 1)
if nil == index then
break
end
indexTable[#indexTable + 1] = index
end
if #indexTable == 0 then
return filePathName
end
local lastIndex = indexTable[#indexTable]
if lastIndex == 1 then
return filePathName
end
local renamePathName= string.sub(filePathName, 1, lastIndex - 1)
if self.isCsbLoad then
renamePathName = renamePathName .. ".csb"
else
renamePathName = renamePathName .. ".json"
end
print("renamePath is", renamePathName)
return renamePathName
end
function SceneEditorTestLayer:defaultPlay()
end
function SceneEditorTestLayer:createMenu()
local menu = cc.Menu:create()
local function pre()
local scene = cc.Scene:create()
scene:addChild(backSceneEditorTest())
@ -118,6 +162,37 @@ function SceneEditorTestLayer:createMenu()
end
end
self.isCsbLoad = false
self.loadtypeLabel = cc.Label:createWithSystemFont(self.loadtypeStr[1], "Arial", 12)
local function changeLoadTypeCallback(tag,sender)
self.isCsbLoad = not self.isCsbLoad
if self.isCsbLoad then
self.loadtypeLabel:setString(self.loadtypeStr[2])
else
self.loadtypeLabel:setString(self.loadtypeStr[1])
end
SceneEditorTestLayer.fileName = self:loadFileChangeHelper(SceneEditorTestLayer.fileName)
if SceneEditorTestLayer.rootNode ~= nil then
self:removeChild(SceneEditorTestLayer.rootNode, true)
SceneEditorTestLayer.rootNode = ccs.SceneReader:getInstance():createNodeWithSceneFile(SceneEditorTestLayer.fileName)
if SceneEditorTestLayer.rootNode == nil then
return
end
self:defaultPlay()
self:addChild(SceneEditorTestLayer.rootNode, 0, 1)
end
end
local loadTypeItem = cc.MenuItemLabel:create(self.loadtypeLabel)
loadTypeItem:registerScriptTapHandler(changeLoadTypeCallback)
local loadtypeMenu = cc.Menu:create()
loadtypeMenu:addChild(loadTypeItem)
loadtypeMenu:setPosition(cc.p(0,0))
loadTypeItem:setPosition(cc.p(VisibleRect:rightTop().x -80,VisibleRect:rightTop().y -30))
self:addChild(loadtypeMenu, 100)
local backMenu = cc.Menu:create()
cc.MenuItemFont:setFontName("Arial")
cc.MenuItemFont:setFontSize(24)
@ -145,9 +220,16 @@ end
function LoadSceneEdtiorFileTest:createGameScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/LoadSceneEdtiorFileTest/FishJoy2.json")
SceneEditorTestLayer.fileName = "scenetest/LoadSceneEdtiorFileTest/FishJoy2.json"
SceneEditorTestLayer.rootNode = node
self:defaultPlay()
return node
end
function LoadSceneEdtiorFileTest:defaultPlay()
end
function LoadSceneEdtiorFileTest:onEnter()
self:createMenu()
self:createTitle()
@ -191,13 +273,9 @@ end
function SpriteComponentTest:createGameScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/SpriteComponentTest/SpriteComponentTest.json")
if nil ~= node then
local action1 = cc.Blink:create(2, 10)
local action2 = cc.Blink:create(2, 5)
local sister1 = node:getChildByTag(10003):getComponent("CCSprite")
sister1:getNode():runAction(action1)
local sister2 = node:getChildByTag(10004):getComponent("CCSprite")
sister2:getNode():runAction(action2)
SceneEditorTestLayer.fileName = "scenetest/SpriteComponentTest/SpriteComponentTest.json"
SceneEditorTestLayer.rootNode = node
self:defaultPlay()
end
return node
@ -209,8 +287,19 @@ function SpriteComponentTest:onEnter()
local root = self:createGameScene()
if nil ~= root then
self:addChild(root, 0, 1)
end
end
function SpriteComponentTest:defaultPlay()
if SceneEditorTestLayer.rootNode ~= nil then
local action1 = cc.Blink:create(2, 10)
local action2 = cc.Blink:create(2, 5)
local sister1 = SceneEditorTestLayer.rootNode:getChildByTag(10003):getComponent("CCSprite")
sister1:getNode():runAction(action1)
local sister2 = SceneEditorTestLayer.rootNode:getChildByTag(10004):getComponent("CCSprite")
sister2:getNode():runAction(action2)
end
end
function SpriteComponentTest.create()
@ -246,14 +335,23 @@ end
function ArmatureComponentTest:createGameScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/ArmatureComponentTest/ArmatureComponentTest.json")
if nil ~= node then
SceneEditorTestLayer.fileName = "scenetest/ArmatureComponentTest/ArmatureComponentTest.json"
SceneEditorTestLayer.rootNode = node
self:defaultPlay()
end
return node
end
function ArmatureComponentTest:defaultPlay()
if SceneEditorTestLayer.rootName ~= nil then
local blowFish = node:getChildByTag(10007):getComponent("CCArmature")
blowFish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
local butterflyfish = node:getChildByTag(10008):getComponent("CCArmature")
butterflyfish:getNode():runAction(CCMoveBy:create(10.0, cc.p(-1000.0, 0)))
butterflyfish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
end
return node
end
function ArmatureComponentTest:onEnter()
@ -299,23 +397,31 @@ end
function UIComponentTest:createGameScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/UIComponentTest/UIComponentTest.json")
if nil ~= node then
local render = node:getChildByTag(10025):getComponent("GUIComponent")
SceneEditorTestLayer.fileName = "scenetest/UIComponentTest/UIComponentTest.json"
SceneEditorTestLayer.rootNode = node
self:defaultPlay()
end
return node
end
function UIComponentTest:defaultPlay()
if SceneEditorTestLayer.rootNode ~= nil then
local render = SceneEditorTestLayer.rootNode:getChildByTag(10025):getComponent("GUIComponent")
local widget = render:getNode()
local button = widget:getChildByName("Button_156")
local function onTouch(sender, eventType)
if eventType == ccui.TouchEventType.began then
local blowFish = node:getChildByTag(10010):getComponent("CCArmature")
local blowFish = SceneEditorTestLayer.rootNode:getChildByTag(10010):getComponent("CCArmature")
blowFish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
local butterflyfish = node:getChildByTag(10011):getComponent("CCArmature")
local butterflyfish = SceneEditorTestLayer.rootNode:getChildByTag(10011):getComponent("CCArmature")
butterflyfish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
end
end
button:addTouchEventListener(onTouch)
end
return node
end
function UIComponentTest:onEnter()
@ -361,7 +467,18 @@ end
function TmxMapComponentTest:createGameScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/TmxMapComponentTest/TmxMapComponentTest.json")
if nil ~= node then
local tmxMap = node:getChildByTag(10015):getComponent("CCTMXTiledMap")
SceneEditorTestLayer.fileName = "scenetest/TmxMapComponentTest/TmxMapComponentTest.json"
SceneEditorTestLayer.rootNode = node
self:defaultPlay()
end
return node
end
function TmxMapComponentTest:defaultPlay()
if SceneEditorTestLayer.rootNode ~= nil then
local tmxMap = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCTMXTiledMap")
local actionTo = cc.SkewTo:create(2, 0.0, 2.0)
local rotateTo = cc.RotateTo:create(2, 61.0)
local actionScaleTo = cc.ScaleTo:create(2, -0.44, 0.47)
@ -374,8 +491,6 @@ function TmxMapComponentTest:createGameScene()
tmxMap:getNode():runAction(cc.Sequence:create(rotateTo, rotateToBack))
tmxMap:getNode():runAction(cc.Sequence:create(actionScaleTo, actionScaleToBack))
end
return node
end
function TmxMapComponentTest:onEnter()
@ -421,13 +536,22 @@ end
function ParticleComponentTest:createGameScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/ParticleComponentTest/ParticleComponentTest.json")
if nil ~= node then
local particle = node:getChildByTag(10020):getComponent("CCParticleSystemQuad")
SceneEditorTestLayer.fileName = "scenetest/ParticleComponentTest/ParticleComponentTest.json"
SceneEditorTestLayer.rootNode = node
self:defaultPlay()
end
return node
end
function ParticleComponentTest:defaultPlay()
if SceneEditorTestLayer.rootNode ~= nil then
local particle = SceneEditorTestLayer.rootNode:getChildByTag(10020):getComponent("CCParticleSystemQuad")
local jump = cc.JumpBy:create(5, cc.p(-500,0), 50, 4)
local action = cc.Sequence:create( jump, jump:reverse())
particle:getNode():runAction(action)
end
return node
end
function ParticleComponentTest:onEnter()
@ -473,13 +597,24 @@ end
function EffectComponentTest:createGameScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/EffectComponentTest/EffectComponentTest.json")
if nil ~= node then
local render = node:getChildByTag(10015):getComponent("CCArmature")
SceneEditorTestLayer.fileName = "scenetest/EffectComponentTest/EffectComponentTest.json"
SceneEditorTestLayer.rootNode = node
self:defaultPlay()
end
return node
end
function EffectComponentTest:defaultPlay()
if SceneEditorTestLayer.rootNode ~= nil then
local render = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCArmature")
local armature = render:getNode()
local function animationEvent(armatureBack,movementType,movementID)
local id = movementID
if movementType == ccs.MovementEventType.loopComplete then
if id == "Fire" then
local audio = node:getChildByTag(10015):getComponent("CCComAudio")
local audio = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCComAudio")
audio:playEffect()
end
end
@ -487,8 +622,6 @@ function EffectComponentTest:createGameScene()
armature:getAnimation():setMovementEventCallFunc(animationEvent)
end
return node
end
function EffectComponentTest:onEnter()
@ -534,13 +667,22 @@ end
function BackgroundComponentTest:createGameScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/BackgroundComponentTest/BackgroundComponentTest.json")
if nil ~= node then
local audio = node:getComponent("CCBackgroundAudio")
audio:playBackgroundMusic()
SceneEditorTestLayer.fileName = "scenetest/BackgroundComponentTest/BackgroundComponentTest.json"
SceneEditorTestLayer.rootNode = node
self:defaultPlay()
end
return node
end
function BackgroundComponentTest:defaultPlay()
if SceneEditorTestLayer.rootNode ~= nil then
local audio = SceneEditorTestLayer.rootNode:getComponent("CCBackgroundAudio")
audio:playBackgroundMusic()
end
end
function BackgroundComponentTest:onEnter()
self:createMenu()
self:createTitle()
@ -583,11 +725,21 @@ end
function AttributeComponentTest:createGameScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/AttributeComponentTest/AttributeComponentTest.json")
local attribute = node:getChildByTag(10015):getComponent("CCComAttribute")
print(string.format("Name: %s, HP: %f, MP: %f", attribute:getString("name"), attribute:getFloat("maxHP"), attribute:getFloat("maxMP")))
if nil ~= node then
SceneEditorTestLayer.fileName = "scenetest/AttributeComponentTest/AttributeComponentTest.json"
SceneEditorTestLayer.rootNode = node
self:defaultPlay()
end
return node
end
function AttributeComponentTest:defaultPlay()
if SceneEditorTestLayer.rootNode ~= nil then
local attribute = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCComAttribute")
print(string.format("Name: %s, HP: %f, MP: %f", attribute:getString("name"), attribute:getFloat("maxHP"), attribute:getFloat("maxMP")))
end
end
function AttributeComponentTest:onEnter()
self:createMenu()
self:createTitle()
@ -631,7 +783,12 @@ end
function TriggerTest:createGameScene()
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/TriggerTest/TriggerTest.json")
if nil ~= node then
SceneEditorTestLayer.fileName = "scenetest/TriggerTest/TriggerTest.json"
SceneEditorTestLayer.rootNode = node
self:defaultPlay()
end
return node
end
@ -658,6 +815,17 @@ function TriggerTest:onEnter()
local root = self:createGameScene()
if nil ~= root then
self:addChild(root, 0, 1)
local function onTouchEvent(touch, event)
if eventType == "began" then
return self:onTouchBegan(touch, event)
elseif eventType == "moved" then
self:onTouchMoved(touch, event)
elseif eventType == "ended" then
self:onTouchEnded(touch, event)
elseif eventType == "cancelled" then
self:onTouchCancelled(touch, event)
end
end
self._touchListener = nil
local listener = cc.EventListenerTouchOneByOne:create()
listener:setSwallowTouches(true)
@ -668,20 +836,27 @@ function TriggerTest:onEnter()
local eventDispatcher = self:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self)
self._touchListener = listener
self:unscheduleUpdate()
local function update(dt)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_UPDATESCENE)
end
self:scheduleUpdateWithPriorityLua(update,0)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_ENTERSCENE)
end
end
end
function TriggerTest:defaultPlay()
end
function TriggerTest:onExit()
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_LEAVESCENE)
self:unscheduleUpdate()
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_LEAVESCENE)
local dispatcher = self:getEventDispatcher()
dispatcher:removeEventListener(self._touchListener)
self._touchListener = nil
ccs.TriggerMng.destroyInstance()
ccs.ArmatureDataManager:destroyInstance()
ccs.SceneReader:destroyInstance()

View File

@ -1,6 +1,5 @@
require "src/ExtensionTest/CocosBuilderTest"
require "src/ExtensionTest/WebProxyTest"
require "src/ExtensionTest/SceneEditorTest"
local LINE_SPACE = 40
local kItemTagBasic = 1000
@ -14,8 +13,7 @@ local ExtensionTestEnum =
TEST_EDITBOX = 4,
TEST_TABLEVIEW = 5,
TEST_SCROLLVIEW = 6,
TEST_STUDIOSCENE = 7,
TEST_MAX_COUNT = 8,
TEST_MAX_COUNT = 7,
}
local testsName =
@ -27,7 +25,6 @@ local testsName =
"EditBoxTest",
"TableViewTest",
"ScrollViewTest",
"CocoStudioSceneTest",
}
@ -1190,7 +1187,6 @@ local CreateExtensionsTestTable =
runEditBoxTest,
runTableViewTest,
runScrollViewTest,
runStudioSceneTest,
}

View File

@ -1,270 +0,0 @@
require "CCBReaderLoad"
function SceneEditorTestLayer(filename)
local layer = cc.Layer:create()
local isCsbLoad = false;
local loadtypeStr = {"change to load \nwith binary file","change to load \nwith json file"}
local loadtypelb = cc.Label:createWithSystemFont(loadtypeStr[1], "Arial", 12);
local filePath = filename
layer.rootNode = nil
function layer:defaultPlay()end
local loadFileChangeHelper = function(filename)
if filename ~= nil then
if isCsbLoad then
return filename .. ".csb"
else
return filename .. ".json"
end
end
return filename
end
local changeLoadTypeCallback = function(sender)
isCsbLoad = not isCsbLoad
loadtypelb:setString(loadtypeStr[isCsbLoad == false and 1 or 2])
local file = loadFileChangeHelper(filePath)
if layer.rootNode ~= nil then
layer:removeChild(layer.rootNode)
layer.rootNode = SceneReader:getInstance():createNodeWithSceneFile(file)
layer:addChild(layer.rootNode, 0, 1)
layer:defaultPlay()
end
end
function layer:enter()
layer.rootNode = SceneReader:getInstance():createNodeWithSceneFile(loadFileChangeHelper(filePath))
layer:addChild(layer.rootNode, 0, 1)
layer:defaultPlay()
end
function layer:exit()
ccs.ArmatureDataManager:destroyInstance()
ccs.SceneReader:destroyInstance()
ccs.ActionManagerEx:destroyInstance()
ccs.GUIReader:destroyInstance()
end
local function onNodeEvent(event)
if "enter" == event then
layer:enter()
elseif "exit" == event then
layer:exit()
end
end
layer:registerScriptHandler(onNodeEvent)
local itemlb = cc.MenuItemLabel:create(loadtypelb)
itemlb:registerScriptTapHandler(changeLoadTypeCallback)
local loadtypemenu = cc.Menu:create(itemlb)
loadtypemenu:setPosition(cc.p(VisibleRect:rightTop().x -50,VisibleRect:rightTop().y -20));
layer:addChild(loadtypemenu,100);
Helper.initWithLayer(layer)
Helper.titleLabel:setString("SceneReader Test LoadSceneEditorFile")
return layer
end
function LoadSceneEdtiorFileTest()
local layer = SceneEditorTestLayer("scenetest/LoadSceneEdtiorFileTest/FishJoy2")
Helper.titleLabel:setString("loadSceneEdtiorFile Test")
return layer
end
function SpriteComponentTest()
local layer = SceneEditorTestLayer("scenetest/SpriteComponentTest/SpriteComponentTest")
Helper.titleLabel:setString("Sprite Component Test")
function layer:defaultPlay()
layer.rootNode:getChildByTag(10003):getComponent("CCSprite"):getNode():runAction(cc.Blink:create(2, 10));
layer.rootNode:getChildByTag(10004):getComponent("CCSprite"):getNode():runAction(cc.Blink:create(2, 5));
end
return layer
end
function ArmatureComponentTest()
local layer = SceneEditorTestLayer("scenetest/ArmatureComponentTest/ArmatureComponentTest")
Helper.titleLabel:setString("Armature Component Test")
function layer:defaultPlay()
layer.rootNode:getChildByTag(10007):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
layer.rootNode:getChildByTag(10008):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
end
return layer
end
function UIComponentTest()
local layer = SceneEditorTestLayer("scenetest/UIComponentTest/UIComponentTest")
Helper.titleLabel:setString("UI Component Test")
local function touchEvent(sender,eventType)
if eventType == ccui.TouchEventType.began then
layer.rootNode:getChildByTag(10010):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
layer.rootNode:getChildByTag(10011):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
end
end
function layer:defaultPlay()
local render = layer.rootNode:getChildByTag(10025):getComponent("GUIComponent")
local widget = render:getNode()
local button = widget:getChildByName("Button_156")
button:addTouchEventListener(touchEvent)
end
return layer
end
function TmxMapComponentTest()
local layer = SceneEditorTestLayer("scenetest/TmxMapComponentTest/TmxMapComponentTest")
Helper.titleLabel:setString("TmxMap Component Test")
function layer:defaultPlay()
local render = layer.rootNode:getChildByTag(10015):getComponent("CCTMXTiledMap")
local skewTo = cc.SkewTo:create(2, 0, 2);
local rotateTo = cc.RotateTo:create(2, 61);
local scaleTo = cc.ScaleTo:create(2, -0.44, 0.47);
local scaleBack = cc.ScaleTo:create(2, 1, 1);
local rotateBack = cc.RotateTo:create(2, 0);
local skewBack = cc.SkewTo:create(2, 0, 0);
render:getNode():runAction(cc.Sequence:create(skewTo, skewBack));
render:getNode():runAction(cc.Sequence:create(rotateTo, rotateBack));
render:getNode():runAction(cc.Sequence:create(scaleTo, scaleBack));
end
return layer
end
function ParticleComponentTest()
local layer = SceneEditorTestLayer("scenetest/ParticleComponentTest/ParticleComponentTest")
Helper.titleLabel:setString("Particle Component Test")
function layer:defaultPlay()
local render = layer.rootNode:getChildByTag(10020):getComponent("CCParticleSystemQuad")
local action = cc.JumpBy:create(5, cc.p(-500,0), 50, 4);
render:getNode():runAction(cc.Sequence:create(action, action:reverse()))
end
return layer
end
function EffectComponentTest()
local layer = SceneEditorTestLayer("scenetest/EffectComponentTest/EffectComponentTest")
Helper.titleLabel:setString("Effect Component Test")
local animationEvent = function(armature,movementType,movementID)
if movementType == ccs.MovementEventType.loopComplete then
if movementID == "Fire" then
layer.rootNode:getChildByTag(10015):getComponent("CCComAudio"):playEffect()
end
end
end
function layer:defaultPlay()
local render = layer.rootNode:getChildByTag(10015):getComponent("CCArmature")
render:getNode():getAnimation():setMovementEventCallFunc(animationEvent);
end
return layer
end
function BackgroundComponentTest()
local layer = SceneEditorTestLayer("scenetest/BackgroundComponentTest/BackgroundComponentTest")
Helper.titleLabel:setString("Background Component Test")
function layer:defaultPlay()
layer.rootNode:getComponent("CCBackgroundAudio"):playBackgroundMusic();
end
return layer
end
function AttributeComponentTest()
local layer = SceneEditorTestLayer("scenetest/AttributeComponentTest/AttributeComponentTest")
Helper.titleLabel:setString("Attribute Component Test")
function layer:defaultPlay()
local attribute = layer.rootNode:getChildByTag(10015):getComponent("CCComAttribute")
cclog("Name: " .. attribute:getString("name") .. ", HP: " .. attribute:getFloat("maxHP") .. ", MP: " .. attribute:getFloat("maxMP"))
end
return layer
end
function TriggerTest()
local layer = SceneEditorTestLayer("scenetest/TriggerTest/TriggerTest")
Helper.titleLabel:setString("Trigger Test")
local function onTouchBegan(touch, event)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHBEGAN)
end
local function onTouchMoved(touch, event)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHMOVED)
end
local function onTouchEnded(touch, event)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHENDED)
end
local function onTouchCancelled(touch, event)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHCANCELLED)
end
local touchListener = cc.EventListenerTouchOneByOne:create()
touchListener:setSwallowTouches(true)
touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN)
touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED)
touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED)
touchListener:registerScriptHandler(onTouchCancelled, cc.Handler.EVENT_TOUCH_CANCELLED)
local eventDispatcher = layer:getEventDispatcher()
eventDispatcher:addEventListenerWithFixedPriority(touchListener, 1)
local function gameLogic(dt)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_UPDATESCENE)
end
local layerExit = layer.exit
function layer:exit()
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_LEAVESCENE)
layer:unschedule(gameLogic)
eventDispatcher:removeEventListener(touchListener)
layerExit(layer)
end
schedule(layer,gameLogic)
function layer:defaultPlay()
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_ENTERSCENE);
end
return layer
end
function runStudioSceneTest()
local scene = cc.Scene:create()
Helper.createFunctionTable = {
LoadSceneEdtiorFileTest,
SpriteComponentTest,
ArmatureComponentTest,
UIComponentTest,
TmxMapComponentTest,
ParticleComponentTest,
EffectComponentTest,
BackgroundComponentTest,
AttributeComponentTest,
TriggerTest,
}
scene:addChild(Helper.createFunctionTable[1]())
scene:addChild(CreateBackMenuItem())
return scene
end