-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolumeControl.lua
More file actions
188 lines (162 loc) ยท 6.1 KB
/
Copy pathvolumeControl.lua
File metadata and controls
188 lines (162 loc) ยท 6.1 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
local loadsave = require( "loadsave" )
local composer = require( "composer" )
local scene = composer.newScene()
local json = require( "json" )
function scene:create( event )
local sceneGroup = self.view
local widget = require ("widget")
--๋ก๋
local loadedEndings = loadsave.loadTable( "endings.json" )
music = loadedEndings.bgMusic
-- ๋ฐฐ๊ฒฝ ์ด๋ก๊ฒ
local black = display.newRect(display.contentWidth/2,display.contentHeight/2,display.contentWidth,display.contentHeight)
black.alpha = 0.5
black:setFillColor(0)
sceneGroup:insert(black)
local settings = {}
settings["fxvolume"] = 0.5
settings["bgvolume"] = 0.5
-- Audio setup
audio.reserveChannels(1)
--local backgroundSound = audio.loadStream(music)
local bgImage = display.newImage("์ด๋ฏธ์ง/ํ์ดํ/์ค์ /์ฐฝ.png", display.contentWidth, display.contentHeight)
bgImage.x = display.contentWidth / 2;
bgImage.y = display.contentHeight / 2;
sceneGroup:insert(bgImage)
-- ๋ฐฐ๊ฒฝ์๋ณผ๋ฅจ๋ฆฌ์ค๋
local function bgSliderListener( event )
local sliderValue = event.value
loadedEndings.slider = sliderValue
local logValue
if sliderValue == nil then sliderValue = 0 end
if (sliderValue > 0) then
logValue = (math.pow(3,sliderValue/100)-1)/(3-1)
else
logValue = 0.0
end
settings["bgvolume"] = logValue
loadedEndings.logValue = logValue
loadsave.saveTable(loadedEndings,"endings.json")
audio.setVolume( settings["bgvolume"] )
end
local background_image = display.newImage("์ด๋ฏธ์ง/์ค์ ์ฐฝ/์๋ฆฌ์กฐ์ ์นธ.png")
background_image.x, background_image.y = display.contentWidth*0.375,display.contentHeight*0.55
sceneGroup:insert(background_image)
local background_image2 = display.newImage("์ด๋ฏธ์ง/์ค์ ์ฐฝ/์๋ฆฌ์กฐ์ ์นธ.png")
background_image2.x, background_image2.y = display.contentWidth * 0.62, display.contentHeight * 0.53
sceneGroup:insert(background_image2)
local options = {
frames = {
{ x=0, y=0, width=41, height=41 },
{ x=41, y=0, width=41, height=41 },
{ x=82, y=0, width=41, height=41 },
{ x=123, y=0, width=41, height=41 },
{ x=164, y=0, width=41, height=41 }
},
sheetContentWidth = 205,
sheetContentHeight = 41
}
local sliderSheet = graphics.newImageSheet( "์ด๋ฏธ์ง/์ค์ ์ฐฝ/sound.png", options )
-- ๋ฐฐ๊ฒฝ์๋ณผ๋ฅจ์ฌ๋ผ์ด๋
local bgSlider = widget.newSlider{
sheet = sliderSheet,
leftFrame = 1,
middleFrame = 2,
rightFrame = 3,
fillFrame = 4,
frameWidth = 41,
frameHeight = 41,
handleFrame = 5,
handleWidth = 41,
handleHeight = 41,
top = 380, x = display.contentCenterX*0.75,
width=380, y=display.contentCenterY*1.1,
value=loadedEndings.slider,
listener = bgSliderListener
}
sceneGroup:insert( bgSlider )
-- ํจ๊ณผ์๋ณผ๋ฅจ๋ฆฌ์ค๋
local function fgSliderListener( event )
local sliderValue = event.value
loadedEndings.slider_effect = sliderValue
local logValue
if sliderValue == nil then sliderValue = 0 end
if (sliderValue > 0) then
logValue = (math.pow(3,sliderValue/100)-1)/(3-1)
else
logValue = 0.0
end
settings["fxvolume"] = logValue
loadedEndings.logValue_effect = logValue
loadsave.saveTable(loadedEndings,"endings.json")
audio.setVolume( settings["bgvolume"] )
end
-- ํจ๊ณผ์๋ณผ๋ฅจ์ฌ๋ผ์ด๋
local fxSlider = widget.newSlider{
sheet = sliderSheet,
leftFrame = 1,
middleFrame = 2,
rightFrame = 3,
fillFrame = 4,
frameWidth = 41,
frameHeight = 41,
handleFrame = 5,
handleWidth = 41,
handleHeight = 41,
top = 380, x = display.contentWidth * 0.62,
width=380, y= display.contentHeight * 0.53,
value=loadedEndings.slider_effect,
listener = fgSliderListener
}
sceneGroup:insert( fxSlider )
-- exit ๋ฒํผ ๋๋ ์ ๋ volumeControl.luaํ์ผ์์ ๋ฒ์ด๋๊ธฐ
local function goback(event)
if event.phase == "began" then
composer.hideOverlay("volumeControl")
end
end
-- exit ๋ฒํผ ์์ฑ ๋ฐ ๋ฒํผ์ ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์ถ๊ฐ
local exit = display.newImage("์ด๋ฏธ์ง/๊ณตํต/x๋ฒํผ.png")
exit.x, exit.y = display.contentWidth*0.745, display.contentHeight*0.35
sceneGroup:insert(exit)
exit:addEventListener("touch",goback)
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