-
Notifications
You must be signed in to change notification settings - Fork 0
/
save.lua
152 lines (110 loc) · 3.87 KB
/
save.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
142
143
144
145
146
147
148
149
150
151
--
-- menu.lua
--
-----------------------------------------------------------------------------------------
local composer = require( "composer" )
local scene = composer.newScene()
-- include Corona's "widget" library
local widget = require "widget"
--------------------------------------------
-- forward declarations and other locals
local saveBtn
local setBtn
local backBtn
-- 'onRelease' event listener for playBtn
local function onsaveBtnRelease()
-- go to level1.lua scene
--composer.gotoScene( "level1", "fade", 500 )
return true -- indicates successful touch
end
local function onbackBtnRelease()
-- go to level1.lua scene
composer.gotoScene( "menu", "fade", 500 )
return true -- indicates successful touch
end
function scene:create( event )
local sceneGroup = self.view
-- Called when the scene's view does not exist.
--
-- INSERT code here to initialize the scene
-- e.g. add display objects to 'sceneGroup', add touch listeners, etc.
-- display a background image
local background = display.newImageRect( "image/title_ex.png", display.actualContentWidth, display.actualContentHeight )
background.anchorX = 0
background.anchorY = 0
background.x = 0 + display.screenOriginX
background.y = 0 + display.screenOriginY
-- create/position logo/title image on upper-half of the screen
local titleLogo = display.newImageRect( "image/logo.png", display.actualContentWidth, display.actualContentHeight )
titleLogo.x = display.contentCenterX
titleLogo.y = 100
-- create a widget button (which will loads level1.lua on release)
soundBtn = widget.newButton{
label = "▶ 세이브 기록",
labelColor = { default={ 1.0 }, over={ 0.5 } },
defaultFile = "ui/btn_nil.png",
overFile = "ui/btn_nil.png",
width = 154, height = 60,
onRelease = onsoundBtnRelease -- event listener function
}
soundBtn.x = display.contentCenterX - 550
soundBtn.y = display.contentHeight - 330
backBtn = widget.newButton{
label = "▶돌아가기",
labelColor = { default={ 1.0 }, over={ 0.5 } },
defaultFile = "ui/btn_nil.png",
overFile = "ui/btn_nil.png",
width = 154, height = 60,
onRelease = onbackBtnRelease -- event listener function
}
backBtn.x = display.contentCenterX - 550
backBtn.y = display.contentHeight - 230
-- all display objects must be inserted into group
sceneGroup:insert( background )
sceneGroup:insert( titleLogo )
sceneGroup:insert( soundBtn )
sceneGroup:insert( backBtn )
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if phase == "will" then
-- Called when the scene is still off screen and is about to move on screen
elseif phase == "did" then
-- Called when the scene is now on screen
--
-- INSERT code here to make the scene come alive
-- e.g. start timers, begin animation, play audio, etc.
end
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if event.phase == "will" then
-- Called when the scene is on screen and is about to move off screen
--
-- INSERT code here to pause the scene
-- e.g. stop timers, stop animation, unload sounds, etc.)
elseif phase == "did" then
-- Called when the scene is now off screen
end
end
function scene:destroy( event )
local sceneGroup = self.view
-- Called prior to the removal of scene's "view" (sceneGroup)
--
-- INSERT code here to cleanup the scene
-- e.g. remove display objects, remove touch listeners, save state, etc.
if playBtn then
playBtn:removeSelf() -- widgets must be manually removed
playBtn = nil
end
end
---------------------------------------------------------------------------------
-- Listener setup
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
-----------------------------------------------------------------------------------------
return scene