-
Notifications
You must be signed in to change notification settings - Fork 0
/
SplashScreen.lua
36 lines (29 loc) · 1.31 KB
/
SplashScreen.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
module(..., package.seeall)
function new()
local localGroup = display.newGroup()
--> This is how we start every single file or "screen" in our folder, except for main.lua
-- and director.lua
--> director.lua is NEVER modified, while only one line in main.lua changes, described in that file
------------------------------------------------------------------------------
------------------------------------------------------------------------------
local time = system.getTimer()
local displayTime = 3000 --3 second splash screen
local background = display.newImage ("erosion_title_image_02.png", 20, 40)
localGroup:insert(background)
--> This sets the background
--> make the splash screen run for the full displayTime
displayTime = displayTime + time
local function update (event)
local splashDelay = system.getTimer() - time
if splashDelay > displayTime then
director:changeScene ("MenuScreen", "fade")
--> Remove runtime events so they do eat up cpu
Runtime:removeEventListener ("enterFrame", update)
end
end
Runtime:addEventListener ("enterFrame", update)
--> This adds the function and listener to the timer runtime event
------------------------------------------------------------------------------
------------------------------------------------------------------------------
return localGroup
end