Repository navigation
Expand file tree
/
Copy pathtitle.lua
More file actions
279 lines (227 loc) · 9.15 KB
/
Copy pathtitle.lua
File metadata and controls
279 lines (227 loc) · 9.15 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
local loadsave = require( "loadsave" )
local composer = require( "composer" )
local scene = composer.newScene()
local json = require( "json" )
function scene:create( event )
local sceneGroup = self.view
-- 객체 생성
-- showoverlay 함수 사용 option
local options = {
isModal = true
}
local background = display.newImageRect("이미지/타이틀/메인.png",display.contentWidth, display.contentHeight)
background.x,background.y = display.contentWidth/2,display.contentHeight/2
sceneGroup:insert(background)
local newgame = display.newImage("이미지/타이틀/새게임.png")
newgame.x,newgame.y = display.contentWidth * 0.42, display.contentHeight * 0.9
sceneGroup:insert(newgame)
local loadgame = display.newImage("이미지/타이틀/로드버튼.png")
loadgame.x,loadgame.y = display.contentWidth * 0.58, display.contentHeight * 0.9
sceneGroup:insert(loadgame)
local titlePopup = display.newImage("이미지/타이틀/이름설정팝업.png")
titlePopup.x,titlePopup.y = display.contentWidth/2,display.contentHeight/2
titlePopup.alpha = 0
sceneGroup:insert(titlePopup)
local titleButton = display.newImage("이미지/타이틀/이름결정.png")
titleButton.x,titleButton.y = display.contentWidth/2, display.contentHeight * 0.65
titleButton.alpha = 0
sceneGroup:insert(titleButton)
local bgm = audio.loadStream( "음악/메인 테마곡.mp3" )
local click1 = audio.loadStream( "음악/스침.wav" )
--audio.setVolume( loadedEndings.logValue )
--audio.play(bgm)
--샘플 볼륨 이미지
local volumeButton = display.newImage("이미지/타이틀/설정.png")
volumeButton.x,volumeButton.y = display.contentWidth * 0.87, display.contentHeight * 0.9
sceneGroup:insert(volumeButton)
--샘플볼륨함수--
local function setVolume(event)
composer.showOverlay( "volumeControl", options )
end
volumeButton:addEventListener("tap",setVolume)
-- 엔딩 제이쓴 파일 생성
local path = system.pathForFile( "endings.json", system.DocumentsDirectory)
local file, errorString = io.open( path, "r" )
if not file then
-- 엔딩 데이터 파일 최초 생성
--엔딩관련 데이터 파일 생성
local endings = {
rainbow = 0,
bonus = 0,
orange = 0,
violet = 0,
act_orange = 0,
act_chung = 0,
act_violet = 0,
red = 0,
yellow = 0,
blue = 0,
green = 0,
purple = 0,
good = 0,
bad = 0,
pastel_red = 0,
pastel_yellow = 0,
pastel_blue = 0,
pastel_green = 0,
pastel_purple = 0,
end_num = 0,
bgMusic = "음악/튜토리얼.mp3",
logValue = "0.5",
slider = 50,
logValue_effect = "0.5",
slider_effect = 50
}
loadsave.saveTable( endings, "endings.json" )
end
loadedEndings = loadsave.loadTable( "endings.json" )
audio.setVolume( loadedEndings.logValue , { channel = 1 })
audio.setVolume( loadedEndings.logValue_effect, { channel = 2 })
audio.play(bgm, { channel = 1, loops = -1 } )
-- showoverlay 함수 사용 option
local options = {
isModal = true
}
local j = 0
local function bigbig1 (event)
--print(event.target.width .. event.target.height)
if (event.target.x-event.x)^2 + (event.target.y-event.y)^2 < 40^2 then
-- i값을 지정해 놓는 이유는 범위 안에서는 크기가 더 늘어나거나 줄어들지 않고, 소리가 연이어 나오지 않음.
if j == 0 then
local backgroundMusicChannel = audio.play(click1, { channel = 2 })
event.target.width = event.target.width*1.1
event.target.height = event.target.height*1.1
j = j + 1
end
elseif (event.target.x-event.x)^2 + (event.target.y-event.y)^2 > 40^2 then
if j == 1 then
event.target.width = event.target.width/11*10
event.target.height = event.target.height/11*10
j = j - 1
end
end
end
local function creditMove(event)
if event.phase == "began" then
--special:removeEventListener("mouse",bigbig1)
composer.showOverlay("title_credit",options)
end
end
--크레딧 버튼
local credit = display.newImage("이미지/크레딧/버튼.png")
credit.x, credit.y = display.contentWidth*0.95,display.contentHeight*0.9
sceneGroup:insert(credit)
--credit:addEventListener("mouse",bigbig1)
credit:addEventListener("touch",creditMove)
-- 엔딩 이미지 객체 생성 및 move 이벤트 리스너 추가
local function move(event)
if event.phase == "began" then
audio.stop(1)
composer.removeScene("title")
composer.gotoScene("title1")
end
end
local ending = display.newImage("이미지/타이틀/엔딩모음.png")
ending.x, ending.y = display.contentWidth*0.05,display.contentHeight*0.9
sceneGroup:insert(ending)
ending:addEventListener("touch",move)
ending:addEventListener("mouse",bigbig1)
volumeButton:addEventListener("mouse",bigbig1)
-- 270.9,98.7
local i = 0
local function bigbig (event)
if ((event.target.x-event.x)^2 < 13000) and ((event.target.y-event.y)^2<1700) then
-- i값을 지정해 놓는 이유는 범위 안에서는 크기가 더 늘어나거나 줄어들지 않고, 소리가 연이어 나오지 않음.
if i == 0 then
-- local backgroundMusicChannel = audio.play(click1)
event.target.width = event.target.width*1.1
event.target.height = event.target.height*1.1
i = i + 1
end
end
if ((event.x-event.target.x)^2 > 9000) then
if i == 1 then
event.target.width = event.target.width/11*10
event.target.height = event.target.height/11*10
i = i - 1
end
elseif ((event.target.y-event.y)^2>1100) then
if i == 1 then
event.target.width = event.target.width/11*10
event.target.height = event.target.height/11*10
i = i - 1
end
end
end
-- newgame 객체 생성 및 openpopup 리스너 추가
local function openPopup()
composer.removeScene("title")
composer.gotoScene("title2")
end
newgame:addEventListener("touch",openPopup)
newgame:addEventListener("mouse",bigbig)
-- 화면전환 이펙트
local options1={
effect = "fade",
time = 2000
}
local function startLoad(event)
--세이브 파일 불러오기--
-- Path for the file to read
local path = system.pathForFile( "settings.json", system.DocumentsDirectory)
-- Open the file handle
local file, errorString = io.open( path, "r" )
if not file or (loadedEndings.end_num==1) then
composer.showOverlay( "nosave", options )
else
audio.pause(1)
composer.removeScene("title")
composer.gotoScene( "view00Room")
-- ,options1
local home = audio.loadStream( "음악/집.mp3" )
audio.setVolume( loadedEndings.logValue )
audio.play(home, { channel = 1 })
end
end
loadgame:addEventListener("touch",startLoad)
loadgame:addEventListener("mouse",bigbig)
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.
end
---------------------------------------------------------------------------------
-- Listener setup
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
-----------------------------------------------------------------------------------------
return scene