-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.lua
152 lines (116 loc) · 4.17 KB
/
settings.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
152
-- Santhosh Nandhakumar --
local composer = require( "composer" )
local scene = composer.newScene()
local widget = require("widget")
---------------------------------------------------------------------------------
-- All code outside of the listener functions will only be executed ONCE
-- unless "composer.removeScene()" is called.
---------------------------------------------------------------------------------
-- local forward references should go here
---------------------------------------------------------------------------------
-- Calculating Centers --
local centerX = display.contentCenterX
local centerY = display.contentCenterY
-- Display objects --
local menuButton
local easyButton
local hardButton
local easyBox
local hardBox
function setLevelEasy()
print("set the easy variable")
hardBox.isVisible = false
easyBox.isVisible = true
end
function setLevelHard()
print("set the hard variable")
hardBox.isVisible = true
easyBox.isVisible = false
end
-- Change to menu scene --
function gotoMenu(event)
display.setDefault( "background", 0, 0, 0 )
composer.setVariable( "selectedTime", selectedTime)
local goToSceneOptions = {
effect = "fade",
time = 300
}
composer.gotoScene( "title", goToSceneOptions)
end
-- "scene:create()" --
function scene:create( event )
local sceneGroup = self.view
-- Initialize the scene here.
-- Example: add display objects to "sceneGroup", add touch listeners, etc.
easyBox = display.newRect( sceneGroup, centerX, centerY - 150, 165,165 )
easyBox.strokeWidth = 10
easyBox:setFillColor( 1,1,1 )
easyBox:setStrokeColor( 1, 0, 0 )
easyBox.xScale = 0.5
easyBox.yScale = 0.5
easyButton = display.newImage (sceneGroup,"assets/Easybutton.png",165,165);
easyButton.x = centerX
easyButton.y = centerY - 150
easyButton.xScale = 0.5
easyButton.yScale = 0.5
easyButton:addEventListener( "tap", setLevelEasy )
hardBox = display.newRect( sceneGroup, centerX, centerY - 50, 165,165 )
hardBox.strokeWidth = 10
hardBox:setFillColor( 1,1,1 )
hardBox:setStrokeColor( 1, 0, 0 )
hardBox.xScale = 0.5
hardBox.yScale = 0.5
hardBox.isVisible = false
hardButton = display.newImage (sceneGroup,"assets/hardButton.png",165,165);
hardButton.x = centerX
hardButton.y = centerY - 50
hardButton.xScale = 0.5
hardButton.yScale = 0.5
hardButton:setStrokeColor( red )
hardButton:addEventListener( "tap", setLevelHard )
menuButton = display.newImage (sceneGroup,"assets/menu.png",174,172);
menuButton.x = centerX
menuButton.y = centerY + 100
menuButton.xScale = 0.40
menuButton.yScale = 0.40
menuButton:addEventListener( "tap", gotoMenu )
end
-- "scene:show()"
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
-- Called when the scene is still off screen (but is about to come on screen).
elseif ( phase == "did" ) then
-- Called when the scene is now on screen.
-- Insert code here to make the scene come alive.
-- Example: start timers, begin animation, play audio, etc.
end
end
-- "scene:hide()"
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
-- Called when the scene is on screen (but is about to go off screen).
-- Insert code here to "pause" the scene.
-- Example: stop timers, stop animation, stop audio, etc.
elseif ( phase == "did" ) then
-- Called immediately after scene goes off screen.
end
end
-- "scene:destroy()"
function scene:destroy( event )
local sceneGroup = self.view
-- Called prior to the removal of scene's view ("sceneGroup").
-- Insert code here to clean up the scene.
-- Example: remove display objects, save state, etc.
end
---------------------------------------------------------------------------------
-- Listener setup
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
---------------------------------------------------------------------------------
return scene