-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenu.lua
62 lines (50 loc) · 1.41 KB
/
menu.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
local composer = require( "composer" )
local scene = composer.newScene()
local widget = require "widget"
local playBtn
local function onPlayBtnRelease()
composer.gotoScene( "difficultyscene", "fade", 500 )
return true -- indicates successful touch
end
function scene:create( event )
local options =
{
loops = -1, -- loop indefinitely
}
music = audio.loadSound("soundeffects/gamemusic.mp3")
audio.play(music, options)
local sceneGroup = self.view
local logoImage = display.newImage( sceneGroup, 'logo.png', display.contentCenterX, 100)
logoImage:scale(0.3, 0.3)
-- Initialize Play Button
playBtn = widget.newButton{
defaultFile = 'playButton.png',
overFile = 'playButtonDown.png',
width=154, height=40,
onRelease = onPlayBtnRelease
}
playBtn.x = display.contentCenterX
playBtn.y = display.contentHeight - 125
sceneGroup:insert( playBtn )
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
end
function scene:destroy( event )
local sceneGroup = self.view
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