-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.lua
100 lines (66 loc) · 2.47 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
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
local composer = require( "composer" )
local scene = composer.newScene()
local tiled = require "com.ponywolf.ponytiled"
local json = require "json"
local sceneTransition = require "sceneTransition"
local listenersModule = require "listeners"
-- -----------------------------------------------------------------------------------
-- Declaração das variáveis
-- -----------------------------------------------------------------------------------
local menu
local newGameButton
local playButton
local fitScreen = require "fitScreen"
local listeners = listenersModule:new()
-- -----------------------------------------------------------------------------------
-- Cenas
-- -----------------------------------------------------------------------------------
-- create()
function scene:create( event )
local sceneGroup = self.view
display.setDefault("magTextureFilter", "nearest")
display.setDefault("minTextureFilter", "nearest")
local menuData = json.decodeFile(system.pathForFile("tiled/menu.json", system.ResourceDirectory)) -- load from json export
menu = tiled.new(menuData, "tiled")
newGameButton = menu:findObject("new game")
playButton = menu:findObject("play")
title = menu:findObject("title")
info = menu:findObject("info")
sceneGroup:insert( menu )
fitScreen.fitMenu( menu, newGameButton, playButton, title )
listeners:add( playButton, "tap", sceneTransition.gotoChooseGameFile )
listeners:add( newGameButton, "tap", sceneTransition.gotoNewGame )
listeners:add( info, "tap", sceneTransition.gotoCredits )
end
-- show()
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
elseif ( phase == "did" ) then
end
end
-- hide()
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
listeners:destroy()
elseif ( phase == "did" ) then
menu:removeSelf()
composer.removeScene( "menu" )
end
end
-- destroy()
function scene:destroy( event )
local sceneGroup = self.view
end
-- -----------------------------------------------------------------------------------
-- Scene event function listeners
-- -----------------------------------------------------------------------------------
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
-- -----------------------------------------------------------------------------------
return scene