-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApplication.lua
66 lines (54 loc) · 1.71 KB
/
Application.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
local mexico = require "mexico"
--
-- Class: App
--
local Application = mexico.class(mexico.Object)
--
-- Constructor
--
function Application:init()
-- create main, background and display layer
self.rootLayer = mexico.Group()
self.backgroundLayer = self.rootLayer:newGroup()
-- init scene director
self.sceneDirector = mexico.SceneDirector()
self.sceneDirector:show(self.mainLayer)
-- listen to system events
Runtime:addEventListener("system", self)
-- register app
mexico.app = self
end
--
-- Hides or changes the appearance of the status bar.
--
-- Parameters:
-- + mode [string] : One of the following values:
-- Hidden, Default, Translucent, Dark
--
function Application:setStatusBar(mode)
display.setStatusBar(display[mode .. "StatusBar"])
end
function Application:onStart(event)
end
function Application:onExit(event)
end
function Application:onSuspend(event)
end
function Application:onResume(event)
end
function Application:system(event)
if event.type == "applicationStart" then self:onStart ({ source = self, name = "start" })
elseif event.type == "applicationExit" then self:onExit ({ source = self, name = "exit" })
elseif event.type == "applicationSuspend" then self:onSuspend ({ source = self, name = "suspend" })
elseif event.type == "applicationResume" then self:onResume ({ source = self, name = "resume" })
end
end
function Application:dispose()
mexico.Object.assert(self)
mexico.app = nil
self.sceneDirector = self.sceneDirector:dispose()
self.display = self.display.dispose()
self.background = self.background.dispose()
self.main = self.main.dispose()
end
return Application