easiest way to make button to *.lua file CORONA SDK

What is the easiest way to make button to *.lua file?

I want to make something like : main.lua (tap button) --> scene1.lua (BACK tap button) --> main.lua

I tried something like this:

local storyboard = require (“storyboard”)
local scene = storyboard.newScene()

local logo tlo = display.newImage(“bg.png”, 360, 640)
local zamow = display.newImage(“1zamow.png”, 185, 340)
local gadgety= display.newImage(“2gadgety.png”, 535, 340)
local facebook = display.newImage(“3facebook.png”, 185, 700)
local oferta = display.newImage(“4oferta.png”, 535, 700)
local cennik = display.newImage(“5cennik.png”, 185, 1060)
local kontakt = display.newImage(“6kontakt.png”, 535, 1060)

function cennik:touch (event)
storyboard.gotoScene(“cennik”, “fade”, 400)

end

cennik:addEventListener( “touch”, cennik )

return scene’

after that I have runtime error:

attempt to concatenate global ‘sceneName’ (a nil value)

I’m new one in Corona so please be nice :slight_smile:

Does your project contain a file named “cennik.lua” ?

Your main.lua file should look like this (restructured from the code you posted)

local storyboard = require ("storyboard") local logo tlo = display.newImage("bg.png", 360, 640) local zamow = display.newImage("1zamow.png", 185, 340) local gadgety= display.newImage("2gadgety.png", 535, 340) local facebook = display.newImage("3facebook.png", 185, 700) local oferta = display.newImage("4oferta.png", 535, 700) local cennik = display.newImage("5cennik.png", 185, 1060) local kontakt = display.newImage("6kontakt.png", 535, 1060) local cennik = display.newRect( display.contentCenterX, display.contentCenterY, 200, 200 ) function cennik:touch (event) local phase = event.phase if phase == "began" then storyboard.gotoScene("cennik", "fade", 400) end return true end cennik:addEventListener( "touch", cennik )

Your cennik.lua file should look something like this (at the most basic level):

local storyboard = require( "storyboard" ) local scene = storyboard.newScene() function scene:createScene( event ) local group = self.view -- your initialisation code end scene:addEventListener( "createScene" ) return scene

Hope that helps!

nope - no reaction tight now. But thanks.

Keep in mind, main.lua isn’t a scene you can go back to.  It’s a launch point:

main.lua -> menu.lua -> scene1.lua -> menu.lua.

Does your project contain a file named “cennik.lua” ?

Your main.lua file should look like this (restructured from the code you posted)

local storyboard = require ("storyboard") local logo tlo = display.newImage("bg.png", 360, 640) local zamow = display.newImage("1zamow.png", 185, 340) local gadgety= display.newImage("2gadgety.png", 535, 340) local facebook = display.newImage("3facebook.png", 185, 700) local oferta = display.newImage("4oferta.png", 535, 700) local cennik = display.newImage("5cennik.png", 185, 1060) local kontakt = display.newImage("6kontakt.png", 535, 1060) local cennik = display.newRect( display.contentCenterX, display.contentCenterY, 200, 200 ) function cennik:touch (event) local phase = event.phase if phase == "began" then storyboard.gotoScene("cennik", "fade", 400) end return true end cennik:addEventListener( "touch", cennik )

Your cennik.lua file should look something like this (at the most basic level):

local storyboard = require( "storyboard" ) local scene = storyboard.newScene() function scene:createScene( event ) local group = self.view -- your initialisation code end scene:addEventListener( "createScene" ) return scene

Hope that helps!

nope - no reaction tight now. But thanks.

Keep in mind, main.lua isn’t a scene you can go back to.  It’s a launch point:

main.lua -> menu.lua -> scene1.lua -> menu.lua.