Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (65 sloc) 2.81 KB
This is the main.lua file. It executes first and, in this demo,
its sole purpose is to set some initial visual settings.
Then, you execute the game or menu scene via Composer.
Composer is the official scene (screen) creation and management
library in Corona; it provides developers with an
easy way to create and transition between individual scenes.
See the Composer Library guide for details:
-- Include the Composer library
local composer = require( "composer" )
-- Removes status bar on iOS
display.setStatusBar( display.HiddenStatusBar )
-- Removes bottom bar on Android
if system.getInfo( "androidApiLevel" ) and system.getInfo( "androidApiLevel" ) < 19 then
native.setProperty( "androidSystemUiVisibility", "lowProfile" )
native.setProperty( "androidSystemUiVisibility", "immersiveSticky" )
-- Are we running on the Corona Simulator?
local isSimulator = "simulator" == system.getInfo( "environment" )
local isMobile = ( "ios" == system.getInfo("platform") ) or ( "android" == system.getInfo("platform") )
-- If we are running in the Corona Simulator, enable debugging keys
-- "F" key shows a visual monitor of our frame rate and memory usage
if isSimulator then
-- Show FPS
local visualMonitor = require( "com.ponywolf.visualMonitor" )
local visMon = visualMonitor:new()
visMon.isVisible = false
local function debugKeys( event )
local phase = event.phase
local key = event.keyName
if phase == "up" then
if key == "f" then
visMon.isVisible = not visMon.isVisible
-- Listen for key events in Runtime
-- See the "key" event documentation for more details:
Runtime:addEventListener( "key", debugKeys )
-- This module turns gamepad axis events and mobile accelerometer events into keyboard
-- events so we don't have to write separate code for joystick, tilt, and keyboard control
require( "com.ponywolf.joykey" ).start()
-- add virtual joysticks to mobile
if isMobile or isSimulator then
local vjoy = require( "com.ponywolf.vjoy" )
local stick = vjoy.newStick()
stick.x, stick.y = 128, display.contentHeight - 128
local button = vjoy.newButton()
button.x, button.y = display.contentWidth - 128, display.contentHeight - 128
-- reserve music channel
-- go to menu screen
composer.gotoScene( "", { params={ } } )
-- Or, instead of the line above, you can cheat skip to a specific level by using the
-- following line, passing to it the JSON file of the level you want to jump to
-- composer.gotoScene( "", { params={ map="scene/game/map/sandbox2.json" } } )
You can’t perform that action at this time.