If you are going to call composer.gotoScene() to load a scene, that Lua module has to be formatted properly as a Composer Scene file. That is at the top you must require composer and create the new scene:
local composer = require("compser") local scene = composer.newScene()
The bottom part of the file needs to implement the four Composer event functions and return the scene to the caller:
function scene:create( event ) local sceneGroup = self.view -- your scene create code here end function scene:show( event ) local sceneGroup = self.view params = event.params if event.phase == "did" then -- start any runtime event handlers, physics, timers, transitions, audio, etc. here. end end function scene:hide( event ) local sceneGroup = self.view if event.phase == "will" then -- -- Stop any runtime event handlers, physics, timers, transitions, audio, etc. here. end end function scene:destroy( event ) local sceneGroup = self.view end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene
You need to put the right code in the right place. I highly recommend you stop working on your app and spend some time learning how to use Composer. We have a bunch of tutorials and guides on using it. The better you understand this the easier your life will be when it comes to actually building the rest of your app.
https://coronalabs.com/resources/tutorials/user-interface-scenes-and-widgets/
https://docs.coronalabs.com/guide/system/composer/index.html
Rob