-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.lua
93 lines (80 loc) · 2.39 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
--[[
*************************************************************
* This script is developed by Arturs Sosins aka ar2rsawseen, http://appcodingeasy.com
* Feel free to distribute and modify code, but keep reference to its creator
*
* Gideros Game Template for developing games. Includes:
* Start scene, pack select, level select, settings, score system and much more
*
* For more information, examples and online documentation visit:
* http://appcodingeasy.com/Gideros-Mobile/Gideros-Mobile-Game-Template
**************************************************************
]]--
--[[
NEED TO DO
Create ScrollableView
Add levels
Create level handling (locking unocking levels, etc maybe even packs)
Add localization
]]--
--setting up some configurations
application:setOrientation(conf.orientation)
application:setLogicalDimensions(conf.width, conf.height)
application:setScaleMode(conf.scaleMode)
application:setFps(conf.fps)
application:setKeepAwake(conf.keepAwake)
--get new dimensions
conf.width = application:getContentWidth()
conf.height = application:getContentHeight()
--create settings instance
sets = Settings.new()
--background music
music = Music.new("audio/main.mp3")
--when music gets enabled
music:addEventListener("onMusicOn", function()
sets:set("music", true, true)
end)
--when music gets disabled
music:addEventListener("onMusicOff", function()
sets:set("music", false, true)
end)
--play music if enabled
if sets:get("music") then
music:on()
end
--sounds
sounds = Sounds.new()
--set up sound events
--when sounds turn on
sounds:addEventListener("onSoundsOn", function()
sets:set("sounds", true, true)
end)
--when sounds turn off
sounds:addEventListener("onSoundsOff", function()
sets:set("sounds", false, true)
end)
--load all your sounds here
--after that you can simply play them as sounds:play("hit")
sounds:add("complete", "audio/complete.mp3")
sounds:add("hit", "audio/hit.wav")
--load packs and level amounts from packs.json
packs = dataSaver.load("packs")
--define scenes
sceneManager = SceneManager.new({
--start scene
["start"] = start,
--options scene
["options"] = options,
--pack select scene
["pack_select"] = pack_select,
--level select scene
["level_select"] = level_select,
--help scene
["help"] = help,
--level itself
["level"] = level
})
--add manager to stage
stage:addChild(sceneManager)
--start start scene
sceneManager:changeScene("start", 1, conf.transition, conf.easing)