2012-08-24 10:07:15 +08:00
|
|
|
require "luaScript/TransitionsTest/TransitionsName"
|
2012-08-23 16:10:50 +08:00
|
|
|
|
|
|
|
|
2012-08-30 15:32:29 +08:00
|
|
|
local SceneIdx = -1
|
|
|
|
local CurSceneNo = 2
|
2012-08-23 16:10:50 +08:00
|
|
|
local TRANSITION_DURATION = 1.2
|
2013-08-20 13:44:37 +08:00
|
|
|
local s = cc.Director:getInstance():getWinSize()
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2012-08-30 15:32:29 +08:00
|
|
|
local function switchSceneTypeNo()
|
2013-04-05 16:13:04 +08:00
|
|
|
if CurSceneNo == 1 then
|
|
|
|
CurSceneNo = 2
|
|
|
|
else
|
|
|
|
CurSceneNo = 1
|
|
|
|
end
|
2012-08-30 15:32:29 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function backAction()
|
2013-04-05 16:13:04 +08:00
|
|
|
SceneIdx = SceneIdx - 1
|
2012-08-23 16:10:50 +08:00
|
|
|
if SceneIdx < 0 then
|
|
|
|
SceneIdx = SceneIdx + Transition_Table.MAX_LAYER
|
2012-08-30 15:32:29 +08:00
|
|
|
end
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
switchSceneTypeNo()
|
2012-08-30 15:32:29 +08:00
|
|
|
return generateTranScene()
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|
|
|
|
|
2012-08-30 15:32:29 +08:00
|
|
|
local function restartAction()
|
2013-04-05 16:13:04 +08:00
|
|
|
return generateTranScene()
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|
|
|
|
|
2012-08-30 15:32:29 +08:00
|
|
|
local function nextAction()
|
2013-04-05 16:13:04 +08:00
|
|
|
SceneIdx = SceneIdx + 1
|
2012-08-23 16:10:50 +08:00
|
|
|
SceneIdx = math.mod(SceneIdx, Transition_Table.MAX_LAYER)
|
|
|
|
|
2012-08-30 15:32:29 +08:00
|
|
|
switchSceneTypeNo()
|
|
|
|
return generateTranScene()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function backCallback(sender)
|
2013-04-05 16:13:04 +08:00
|
|
|
local scene = backAction()
|
2013-08-20 13:44:37 +08:00
|
|
|
cc.Director:getInstance():replaceScene(scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|
|
|
|
|
2012-08-30 15:32:29 +08:00
|
|
|
local function restartCallback(sender)
|
2013-04-05 16:13:04 +08:00
|
|
|
local scene = restartAction()
|
2013-08-20 13:44:37 +08:00
|
|
|
cc.Director:getInstance():replaceScene(scene)
|
2012-08-30 15:32:29 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function nextCallback(sender)
|
2013-04-05 16:13:04 +08:00
|
|
|
local scene = nextAction()
|
2013-08-20 13:44:37 +08:00
|
|
|
cc.Director:getInstance():replaceScene(scene)
|
2012-08-30 15:32:29 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------
|
|
|
|
-- TestLayer1
|
|
|
|
-----------------------------
|
2012-08-23 16:10:50 +08:00
|
|
|
local function createLayer1()
|
2013-08-20 13:44:37 +08:00
|
|
|
local layer = cc.Layer:create()
|
2013-04-05 16:13:04 +08:00
|
|
|
local x, y = s.width, s.height
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-08-20 13:44:37 +08:00
|
|
|
local bg1 = cc.Sprite:create(s_back1)
|
|
|
|
bg1:setPosition(cc.p(s.width / 2, s.height / 2))
|
2013-04-05 16:13:04 +08:00
|
|
|
layer:addChild(bg1, -1)
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-08-20 13:44:37 +08:00
|
|
|
local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32)
|
2013-04-05 16:13:04 +08:00
|
|
|
layer:addChild(titleLabel)
|
2013-08-20 13:44:37 +08:00
|
|
|
titleLabel:setColor(cc.c3b(255,32,32))
|
2012-08-23 16:10:50 +08:00
|
|
|
titleLabel:setPosition(x / 2, y - 100)
|
|
|
|
|
2013-08-20 13:44:37 +08:00
|
|
|
local label = cc.LabelTTF:create("SCENE 1", "Marker Felt", 38)
|
|
|
|
label:setColor(cc.c3b(16,16,255))
|
2012-08-23 16:10:50 +08:00
|
|
|
label:setPosition(x / 2, y / 2)
|
|
|
|
layer:addChild(label)
|
|
|
|
|
|
|
|
-- menu
|
2013-08-20 13:44:37 +08:00
|
|
|
local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2)
|
|
|
|
local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2)
|
|
|
|
local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2)
|
2013-04-05 16:13:04 +08:00
|
|
|
item1:registerScriptTapHandler(backCallback)
|
|
|
|
item2:registerScriptTapHandler(restartCallback)
|
|
|
|
item3:registerScriptTapHandler(nextCallback)
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-08-20 13:44:37 +08:00
|
|
|
local menu = cc.Menu:create()
|
2013-04-05 16:13:04 +08:00
|
|
|
menu:addChild(item1)
|
|
|
|
menu:addChild(item2)
|
|
|
|
menu:addChild(item3)
|
2013-08-20 13:44:37 +08:00
|
|
|
menu:setPosition(cc.p(0, 0))
|
|
|
|
item1:setPosition(cc.p(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
|
|
|
item2:setPosition(cc.p(s.width / 2, item2:getContentSize().height / 2))
|
|
|
|
item3:setPosition(cc.p(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
2012-08-23 16:10:50 +08:00
|
|
|
|
|
|
|
layer:addChild(menu, 1)
|
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
return layer
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------
|
|
|
|
-- TestLayer2
|
|
|
|
-----------------------------
|
|
|
|
local function createLayer2()
|
2013-08-20 13:44:37 +08:00
|
|
|
local layer = cc.Layer:create()
|
2013-04-05 16:13:04 +08:00
|
|
|
local x, y = s.width, s.height
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-08-20 13:44:37 +08:00
|
|
|
local bg1 = cc.Sprite:create(s_back2)
|
|
|
|
bg1:setPosition(cc.p(s.width / 2, s.height / 2))
|
2013-04-05 16:13:04 +08:00
|
|
|
layer:addChild(bg1, -1)
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-08-20 13:44:37 +08:00
|
|
|
local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 )
|
2012-08-23 16:10:50 +08:00
|
|
|
layer:addChild(titleLabel)
|
2013-08-20 13:44:37 +08:00
|
|
|
titleLabel:setColor(cc.c3b(255,32,32))
|
2012-08-23 16:10:50 +08:00
|
|
|
titleLabel:setPosition(x / 2, y - 100)
|
|
|
|
|
2013-08-20 13:44:37 +08:00
|
|
|
local label = cc.LabelTTF:create("SCENE 2", "Marker Felt", 38)
|
|
|
|
label:setColor(cc.c3b(16,16,255))
|
2012-08-23 16:10:50 +08:00
|
|
|
label:setPosition(x / 2, y / 2)
|
|
|
|
layer:addChild(label)
|
|
|
|
|
|
|
|
-- menu
|
2013-08-20 13:44:37 +08:00
|
|
|
local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2)
|
|
|
|
local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2)
|
|
|
|
local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2)
|
2013-04-05 16:13:04 +08:00
|
|
|
item1:registerScriptTapHandler(backCallback)
|
|
|
|
item2:registerScriptTapHandler(restartCallback)
|
|
|
|
item3:registerScriptTapHandler(nextCallback)
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-08-20 13:44:37 +08:00
|
|
|
local menu = cc.Menu:create()
|
2013-04-05 16:13:04 +08:00
|
|
|
menu:addChild(item1)
|
|
|
|
menu:addChild(item2)
|
|
|
|
menu:addChild(item3)
|
2013-08-20 13:44:37 +08:00
|
|
|
menu:setPosition(cc.p(0, 0))
|
|
|
|
item1:setPosition(cc.p(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
|
|
|
item2:setPosition(cc.p(s.width / 2, item2:getContentSize().height / 2))
|
|
|
|
item3:setPosition(cc.p(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
2012-08-23 16:10:50 +08:00
|
|
|
|
|
|
|
layer:addChild(menu, 1)
|
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
return layer
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------
|
|
|
|
-- Create Transition Test
|
|
|
|
-----------------------------
|
|
|
|
local function createTransition(index, t, scene)
|
2013-08-20 13:44:37 +08:00
|
|
|
cc.Director:getInstance():setDepthTest(false)
|
2013-04-05 16:13:04 +08:00
|
|
|
|
|
|
|
if firstEnter == true then
|
|
|
|
firstEnter = false
|
|
|
|
return scene
|
|
|
|
end
|
|
|
|
|
|
|
|
if index == Transition_Table.CCTransitionJumpZoom then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionJumpZoom:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionProgressRadialCCW then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionProgressRadialCCW:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionProgressRadialCW then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionProgressRadialCW:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionProgressHorizontal then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionProgressHorizontal:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionProgressVertical then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionProgressVertical:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionProgressInOut then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionProgressInOut:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionProgressOutIn then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionProgressOutIn:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionCrossFade then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionCrossFade:create(t, scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.TransitionPageForward then
|
2013-08-20 13:44:37 +08:00
|
|
|
cc.Director:getInstance():setDepthTest(true)
|
|
|
|
scene = cc.TransitionPageTurn:create(t, scene, false)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.TransitionPageBackward then
|
2013-08-20 13:44:37 +08:00
|
|
|
cc.Director:getInstance():setDepthTest(true)
|
|
|
|
scene = cc.TransitionPageTurn:create(t, scene, true)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionFadeTR then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFadeTR:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionFadeBL then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFadeBL:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionFadeUp then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFadeUp:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionFadeDown then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFadeDown:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionTurnOffTiles then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionTurnOffTiles:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionSplitRows then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionSplitRows:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionSplitCols then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionSplitCols:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionFade then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFade:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.FadeWhiteTransition then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFade:create(t, scene, cc.c3b(255, 255, 255))
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.FlipXLeftOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER )
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.FlipXRightOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER )
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.FlipYUpOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_UP_OVER)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.FlipYDownOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_DOWN_OVER )
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.FlipAngularLeftOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER )
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.FlipAngularRightOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER )
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.ZoomFlipXLeftOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionZoomFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER )
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.ZoomFlipXRightOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionZoomFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER )
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.ZoomFlipYUpOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionZoomFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_UP_OVER)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.ZoomFlipYDownOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionZoomFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_DOWN_OVER )
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.ZoomFlipAngularLeftOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionZoomFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER )
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.ZoomFlipAngularRightOver then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionZoomFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER )
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionShrinkGrow then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionShrinkGrow:create(t, scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionRotoZoom then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionRotoZoom:create(t, scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionMoveInL then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionMoveInL:create(t, scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionMoveInR then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionMoveInR:create(t, scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionMoveInT then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionMoveInT:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionMoveInB then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionMoveInB:create(t, scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionSlideInL then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionSlideInL:create(t, scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionSlideInR then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionSlideInR:create(t, scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionSlideInT then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionSlideInT:create(t, scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
elseif index == Transition_Table.CCTransitionSlideInB then
|
2013-08-20 13:44:37 +08:00
|
|
|
scene = cc.TransitionSlideInB:create(t, scene)
|
2013-04-05 16:13:04 +08:00
|
|
|
end
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
return scene
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|
|
|
|
|
2012-08-30 15:32:29 +08:00
|
|
|
function generateTranScene()
|
2013-08-20 13:44:37 +08:00
|
|
|
local scene = cc.Scene:create()
|
2012-08-23 16:10:50 +08:00
|
|
|
local layer = nil
|
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
if CurSceneNo == 1 then
|
|
|
|
layer = createLayer1()
|
|
|
|
elseif CurSceneNo == 2 then
|
|
|
|
layer = createLayer2()
|
|
|
|
end
|
2012-08-23 16:10:50 +08:00
|
|
|
|
|
|
|
scene:addChild(layer)
|
2013-04-05 16:13:04 +08:00
|
|
|
scene:addChild(CreateBackMenuItem())
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2012-08-30 15:32:29 +08:00
|
|
|
return createTransition(SceneIdx, TRANSITION_DURATION, scene)
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function TransitionsTest()
|
2013-04-05 16:13:04 +08:00
|
|
|
cclog("TransitionsTest")
|
2013-08-20 13:44:37 +08:00
|
|
|
local scene = cc.Scene:create()
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
SceneIdx = -1
|
|
|
|
CurSceneNo = 2
|
|
|
|
firstEnter = true
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
return nextAction()
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|