-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwarning.lua
76 lines (56 loc) · 2.02 KB
/
warning.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
module(..., package.seeall)
-- -----------------------------------------------------------------------------------
-- Declaração das variáveis
-- -----------------------------------------------------------------------------------
local M = { }
local json = require "json"
local tiled = require "com.ponywolf.ponytiled"
local sceneTransition = require "sceneTransition"
local listenersModule = require "listeners"
local persistence = require "persistence"
local message
local listeners = listenersModule:new()
-- -----------------------------------------------------------------------------------
-- Listeners
-- -----------------------------------------------------------------------------------
local function accept( event )
if ( message == "resetGame" ) then
persistence.resetGame()
transition.fadeOut( warning )
timer.performWithDelay( 200, sceneTransition.gotoHouse )
else
sceneTransition.gotoMenu()
end
listeners:destroy()
end
local function decline( event )
transition.fadeOut( warning )
listeners:destroy()
end
-- -----------------------------------------------------------------------------------
-- Cenas
-- -----------------------------------------------------------------------------------
-- create()
function M.show( message_ )
local warningData = json.decodeFile(system.pathForFile("tiled/warning.json", system.ResourceDirectory))
local time = 1000
warning = tiled.new(warningData, "tiled")
warning.y = warning.y - 32
acceptButton = warning:findObject( "acceptButton" )
declineButton = warning:findObject( "declineButton" )
transition.fadeIn( warning:findObject( "background" ), { time = time } )
transition.fadeIn( warning:findObject( "blackBackground" ), { time = time } )
message = message_
if ( message ) then
listeners:add( acceptButton, "tap", accept )
listeners:add( declineButton, "tap", decline )
if ( message == "resetGame" ) then
local resetGame = warning:findObject( "resetGame" )
resetGame.alpha = 1
end
else
transition.fadeOut( warning )
end
return warning
end
return M