-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.lua
141 lines (114 loc) · 4.95 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
--[[
This code is MIT licensed, see http://www.opensource.org/licenses/mit-license.php
(C) 2010 - 2011 Gideros Mobile
]]
local sceneManager = SceneManager.new({
["scene1"] = Scene1,
["scene2"] = Scene2,
["scene3"] = Scene3,
["scene4"] = Scene4,
})
sceneManager:addEventListener("transitionBegin", function() print("manager - transition begin") end)
sceneManager:addEventListener("transitionEnd", function() print("manager - transition end") end)
stage:addChild(sceneManager)
local transitions = {
SceneManager.moveFromLeft,
SceneManager.moveFromRight,
SceneManager.moveFromBottom,
SceneManager.moveFromTop,
SceneManager.moveFromLeftWithFade,
SceneManager.moveFromRightWithFade,
SceneManager.moveFromBottomWithFade,
SceneManager.moveFromTopWithFade,
SceneManager.overFromLeft,
SceneManager.overFromRight,
SceneManager.overFromBottom,
SceneManager.overFromTop,
SceneManager.overFromLeftWithFade,
SceneManager.overFromRightWithFade,
SceneManager.overFromBottomWithFade,
SceneManager.overFromTopWithFade,
SceneManager.fade,
SceneManager.crossFade,
SceneManager.flip,
SceneManager.flipWithFade,
SceneManager.flipWithShade,
}
local scenes = {"scene1", "scene2", "scene3", "scene4"}
local currentScene = 1
local function nextScene()
local next = scenes[currentScene]
currentScene = currentScene + 1
if currentScene > #scenes then
currentScene = 1
end
return next
end
local moveButton = Button.new(Bitmap.new(Texture.new("gfx/move-up.png")), Bitmap.new(Texture.new("gfx/move-down.png")))
moveButton:setPosition(20, 10)
stage:addChild(moveButton)
local moveWithFadeButton = Button.new(Bitmap.new(Texture.new("gfx/move with fade-up.png")), Bitmap.new(Texture.new("gfx/move with fade-down.png")))
moveWithFadeButton:setPosition(160, 10)
stage:addChild(moveWithFadeButton)
local overButton = Button.new(Bitmap.new(Texture.new("gfx/over-up.png")), Bitmap.new(Texture.new("gfx/over-down.png")))
overButton:setPosition(20, 50)
stage:addChild(overButton)
local overWithFadeButton = Button.new(Bitmap.new(Texture.new("gfx/over with fade-up.png")), Bitmap.new(Texture.new("gfx/over with fade-down.png")))
overWithFadeButton:setPosition(160, 50)
stage:addChild(overWithFadeButton)
local fadeButton = Button.new(Bitmap.new(Texture.new("gfx/fade-up.png")), Bitmap.new(Texture.new("gfx/fade-down.png")))
fadeButton:setPosition(20, 90)
stage:addChild(fadeButton)
local crossfadeButton = Button.new(Bitmap.new(Texture.new("gfx/crossfade-up.png")), Bitmap.new(Texture.new("gfx/crossfade-down.png")))
crossfadeButton:setPosition(160, 90)
stage:addChild(crossfadeButton)
local flipButton = Button.new(Bitmap.new(Texture.new("gfx/flip-up.png")), Bitmap.new(Texture.new("gfx/flip-down.png")))
flipButton:setPosition(20, 130)
stage:addChild(flipButton)
local flipWithFadeButton = Button.new(Bitmap.new(Texture.new("gfx/flip with fade-up.png")), Bitmap.new(Texture.new("gfx/flip with fade-down.png")))
flipWithFadeButton:setPosition(160, 130)
stage:addChild(flipWithFadeButton)
local flipWithShadeButton = Button.new(Bitmap.new(Texture.new("gfx/flip with shade-up.png")), Bitmap.new(Texture.new("gfx/flip with shade-down.png")))
flipWithShadeButton:setPosition(20, 170)
stage:addChild(flipWithShadeButton)
moveButton:addEventListener("click",
function()
local transition = transitions[math.random(1, 4)]
sceneManager:changeScene(nextScene(), 1, transition, easing.outBack, { eventFilter={Event.MOUSE_DOWN} } )
end)
moveWithFadeButton:addEventListener("click",
function()
local transition = transitions[math.random(5, 8)]
sceneManager:changeScene(nextScene(), 1, transition, easing.outQuadratic, { eventFilter={Event.MOUSE_DOWN} } )
end)
overButton:addEventListener("click",
function()
local transition = transitions[math.random(9, 12)]
sceneManager:changeScene(nextScene(), 1, transition, easing.outBounce, { userData = "outBounce" } )
end)
overWithFadeButton:addEventListener("click",
function()
local transition = transitions[math.random(13, 16)]
sceneManager:changeScene(nextScene(), 1, transition, easing.outQuadratic, { userData = "hello", eventFilter={Event.MOUSE_DOWN} } )
end)
fadeButton:addEventListener("click",
function()
sceneManager:changeScene(nextScene(), 1, SceneManager.fade, easing.linear)
end)
crossfadeButton:addEventListener("click",
function()
sceneManager:changeScene(nextScene(), 1, SceneManager.crossfade, easing.linear)
end)
flipButton:addEventListener("click",
function()
sceneManager:changeScene(nextScene(), 1, SceneManager.flip, easing.inOutQuadratic)
end)
flipWithFadeButton:addEventListener("click",
function()
sceneManager:changeScene(nextScene(), 1, SceneManager.flipWithFade, easing.inOutQuadratic)
end)
flipWithShadeButton:addEventListener("click",
function()
sceneManager:changeScene(nextScene(), 1, SceneManager.flipWithShade, easing.inOutQuadratic)
end)
sceneManager:changeScene(nextScene())