Skip to content

Instantly share code, notes, and snippets.

@tomekc
Created December 10, 2019 22:03
Show Gist options
  • Save tomekc/06a1ab76042dc72fe985ee1b35a8a77e to your computer and use it in GitHub Desktop.
Save tomekc/06a1ab76042dc72fe985ee1b35a8a77e to your computer and use it in GitHub Desktop.
Corona SDK - scene template
-- Include modules/libraries
local composer = require "composer"
-- Variables local to scene
--
-- Create a new Composer scene
local scene = composer.newScene()
-- This function is called when scene is created
function scene:create( event )
local sceneGroup = self.view -- Add scene display objects to this group
end
local function enterFrame(event)
local elapsed = event.time
end
-- This function is called when scene comes fully on screen
function scene:show( event )
local phase = event.phase
if ( phase == "will" ) then
Runtime:addEventListener( "enterFrame", enterFrame )
elseif ( phase == "did" ) then
end
end
-- This function is called when scene goes fully off screen
function scene:hide( event )
local phase = event.phase
if ( phase == "will" ) then
elseif ( phase == "did" ) then
Runtime:removeEventListener( "enterFrame", enterFrame )
end
end
-- This function is called when scene is destroyed
function scene:destroy( event )
--collectgarbage()
end
scene:addEventListener("create")
scene:addEventListener("show")
scene:addEventListener("hide")
scene:addEventListener("destroy")
return scene
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment