-
Notifications
You must be signed in to change notification settings - Fork 0
/
startScreen.lua
75 lines (66 loc) · 2.26 KB
/
startScreen.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
-----------------------------------------------------------------------------------------
--
-- startScreen.lua
--
-- Joe Cracchiolo
-- Splash screen the player sees when the game is first started
-----------------------------------------------------------------------------------------
------ Overhead -------------------------------------------------------------------------
-- Get local reference to the game globals
local game = globalGame
-- Create the act object
local act = game.newAct()
local widget = require( "widget" )
----- Variables -------------------------------------------------------------------------
----- Functions --------------------------------------------------------------------------
-- Move to the start of the game
local function startGame ( event )
game.gotoAct( "mainAct", "fade" )
end
-- Move to the options screen
local function gotoOptions ( event )
game.gotoAct( "debugMenu", "fade" )
end
-- Handle new frame events
function act:enterFrame()
-- Continuous scroll of the endless space background
for i = 1, 2 do
local bg = marsBgs[i]
bg.y = bg.y + 0.1
if bg.y > act.yMax then
bg.y = act.yMin - act.height*2
end
end
end
------------------------- Start of Activity ----------------------------------------------
-- Init the act
function act:init()
-- Space background images (2 for continuous scrolling)
marsBgs = {
act:newImage( "titleMars.jpg", { y = act.yMin, anchorY = 0, height = act.height*2 } ),
act:newImage( "titleMars.jpg", { y = act.yMin - act.height*2, anchorY = 0, height = act.height*2 } ),
}
local imageMask = act:newImage( "titleScreenMask.png", { width = act.width } )
local title = display.newText( act.group, "Mars Explorer", act.xCenter, act.yMin + 60, native.systemFontBold, 40 )
local startBtn = widget.newButton
{
label = "Start",
fontSize = 30,
x = act.xCenter,
y = act.yMax - 120,
onRelease = startGame
}
act.group:insert( startBtn )
local optionsBtn = widget.newButton
{
label = "Options",
fontSize = 30,
x = act.xCenter,
y = act.yMax - 70,
onRelease = gotoOptions
}
act.group:insert( optionsBtn )
end
------------------------- End of Activity ---------------------------------------------------
-- Corona needs the scene object returned from the act file
return act.scene