-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.lua
executable file
·78 lines (63 loc) · 2.32 KB
/
main.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
--[[
This is the main.lua file. It executes first and in this demo
is sole purpose is to set some initial visual settings.
-- ]]
local device = require "com.ponywolf.device"
if device.isAndroid then
if system.getInfo( "androidApiLevel" ) and system.getInfo( "androidApiLevel" ) < 19 then
native.setProperty( "androidSystemUiVisibility", "lowProfile" )
else
native.setProperty( "androidSystemUiVisibility", "immersiveSticky" )
end
end
if device.isiOS then -- don't turn off background music, remove status bar on iOS
display.setStatusBar( display.HiddenStatusBar )
native.setProperty( "prefersHomeIndicatorAutoHidden", true )
native.setProperty( "preferredScreenEdgesDeferringSystemGestures", true )
audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode)
end
-- reserve audio for menu and bgsound
local snd = require "com.ponywolf.ponysound"
snd:setVolume(0.5)
snd:batch("blip", "laser", "explode", "jump", "thud", "coin")
snd:loadMusic("snd/venus.wav")
snd:playMusic()
-- if we are load our visual monitor that let's a press of the "F"
-- key show our frame rate and memory usage, "P" to show physics
if device.isSimulator then
-- show FPS
local visualMonitor = require( "com.ponywolf.visualMonitor" )
local visMon = visualMonitor:new()
visMon.isVisible = false
-- show/hide physics
local function key(event)
local phase = event.phase
local name = event.keyName
if phase == "up" then
if name == "f10" then
physics.show = not physics.show
if physics.show then
physics.setDrawMode( "hybrid" )
else
physics.setDrawMode( "normal" )
end
elseif name == "`" then
visMon.isVisible = not visMon.isVisible
elseif name == "f12" then
device.screenshot()
elseif name == "escape" then
-- quick exit
end
end
end
Runtime:addEventListener( "key", key )
end
-- this module turns gamepad axis events into keyboard
-- events so we don't have to write separate code
-- for joystick and keyboard control
require("com.ponywolf.joykey").start()
-- go to menu screen
display.setDefault("background", 0.2,0.2,0.2)
local scenes = require "scenes"
local template = scenes.new("scene.menu")
scenes.show("menu", {transition = "fade", time = 250 })