Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.