Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Composer not working
Started by filippo66627 Jan 14 2020 02:28 PM

60 replies to this topic
[TOPIC CONTROLS]
Page 1 of 3 1 2 3
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

hi im trying to switch scene from the main too another scene and it doesnt work i get lots of errors, here its my code 

main :

 

 local composer = require("composer")

composer.gotoScene ("home",options )
 
home 
 
composer = require("composer") 
widget = require("widget")
 
 
device_width = display.contentWidth --larghezza in pixel dello schermo del tel
device_height = display.contentHeight --altezza in pixel dello schermo del tel
 
local sfondo = display.newImageRect( "Sfondi/menu2.png",device_width,device_height)
 
sfondo.x= device_width/2
sfondo.y= device_height/2
 
ty all 

 



[TOPIC: post.html]
#2

pixec

[GLOBAL: userInfoPane.html]
pixec
  • Contributor

  • 210 posts
  • Corona SDK

https://docs.coronalabs.com/guide/system/composer/index.html

[TOPIC: post.html]
#3

jdsmedeirosbr

[GLOBAL: userInfoPane.html]
jdsmedeirosbr
  • Enthusiast

  • 98 posts
  • Corona SDK

main is correct! You have to use the Scene Template in your home to create a valid scene in it. Pixec left the link above for you to take the scene code template and insert it into your home.



[TOPIC: post.html]
#4

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

main is correct! You have to use the Scene Template in your home to create a valid scene in it. Pixec left the link above for you to take the scene code template and insert it into your home.

 i did and i stil get this error https://gyazo.com/da16a0f8c70d711523b452c62c813085 my menu2.lua file is this :

 

local composer = require ("composer")
 
 
local scene = composer.newScene()
 
-- -----------------------------------------------------------------------------------
-- Code outside of the scene event functions below will only be executed ONCE unless
-- the scene is removed entirely (not recycled) via "composer.removeScene()"
-- -----------------------------------------------------------------------------------
 
 
 
 
-- -----------------------------------------------------------------------------------
-- Scene event functions
-- -----------------------------------------------------------------------------------
 
-- create()
function scene:create( event )
 
    local sceneGroup = self.view
    -- Code here runs when the scene is first created but has not yet appeared on screen
 
end
 
 
-- show()
function scene:show( event )
 
    local sceneGroup = self.view
    local phase = event.phase
 
    if ( phase == "will" ) then
        -- Code here runs when the scene is still off screen (but is about to come on screen)
 
    elseif ( phase == "did" ) then
        -- Code here runs when the scene is entirely on screen
 
    end
end
 
 
-- hide()
function scene:hide( event )
 
    local sceneGroup = self.view
    local phase = event.phase
 
    if ( phase == "will" ) then
        -- Code here runs when the scene is on screen (but is about to go off screen)
 
    elseif ( phase == "did" ) then
        -- Code here runs immediately after the scene goes entirely off screen
 
    end
end
 
 
-- destroy()
function scene:destroy( event )
 
    local sceneGroup = self.view
    -- Code here runs prior to the removal of scene's view
 
end
 
 
-- -----------------------------------------------------------------------------------
-- Scene event function listeners
-- -----------------------------------------------------------------------------------
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
-- -----------------------------------------------------------------------------------
 
return scene
 
device_width = display.contentWidth --larghezza in pixel dello schermo del tel
device_height = display.contentHeight --altezza in pixel dello schermo del tel
 
--impostazione sfondo 
local sfondo = display.newImageRect( "sfondonero.png",device_width,device_height)
 
sfondo.x= device_width/2
sfondo.y= device_height/2
 
--richiamo libreria per i widgets 
local widget = require("widget")
 
--funzione che viene richiamata quando il bottone viene premuto quindi quando è nello stato "ended" 
 
local function handleButtonEvent ( event )
  local phase = event.phase 
  if "ended" == event.phase then 
    print ("Hello World") 
  end 
end 
  
ty so much 


[TOPIC: post.html]
#5

jdsmedeirosbr

[GLOBAL: userInfoPane.html]
jdsmedeirosbr
  • Enthusiast

  • 98 posts
  • Corona SDK

All your code has to be within the scene structure, you put your code after the return scene! return scene is the last code of your file, there can be nothing below it. try placing your code below: function scene: create (event)  local sceneGroup = self.view

[TOPIC: post.html]
#6

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,976 posts
  • Corona SDK

You can't have code after 'return scene'. 

 

EDIT: what he said



[TOPIC: post.html]
#7

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

All your code has to be within the scene structure, you put your code after the return scene! return scene is the last code of your file, there can be nothing below it. try placing your code below: function scene: create (event)  local sceneGroup = self.view

i did and im still getting the same error,my code is between the template and here's the code (ty)

 
local composer = require( "composer" )
 
local scene = composer.newScene()
 
-- -----------------------------------------------------------------------------------
-- Code outside of the scene event functions below will only be executed ONCE unless
-- the scene is removed entirely (not recycled) via "composer.removeScene()"
-- -----------------------------------------------------------------------------------
 
 
 
 
-- -----------------------------------------------------------------------------------
-- Scene event functions
-- -----------------------------------------------------------------------------------
 
-- create()
function scene:create( event )
 
    local sceneGroup = self.view
    device_width = display.contentWidth --larghezza in pixel dello schermo del tel
device_height = display.contentHeight --altezza in pixel dello schermo del tel
local coomposer = require ("composer")
--impostazione sfondo 
local sfondo = display.newImageRect( "sfondonero.png",device_width,device_height)
 
sfondo.x= device_width/2
sfondo.y= device_height/2
 
--richiamo libreria per i widgets 
local widget = require("widget")
 
--funzione che viene richiamata quando il bottone viene premuto quindi quando è nello stato "ended" 
 
local function handleButtonEvent ( event )
  local phase = event.phase 
  if "ended" == event.phase then 
    print ("Hello World") 
  end 
end 
 
--creazione bottone numero 1 
local button1 = widget.newButton
 
{
  left = 35 ,
  top = 400 ,
  width = 22 ,
  height = 54,
  defaultFile = ("Sfondi/icons/1.png"),
  overFile = ("Sfondi/icons/1.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone numero 2
local button2 = widget.newButton
 
{
  left = 120 ,
  top = 400 ,
  width = 22 ,
  height = 54,
  defaultFile = ("Sfondi/icons/2.png"),
  overFile = ("Sfondi/icons/2.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone numero 3 
local button3 = widget.newButton
 
{
  left = 205 ,
  top = 400 ,
  width = 22 ,
  height = 54,
  defaultFile = ("Sfondi/icons/3.png"),
  overFile = ("Sfondi/icons/3.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone addizione 
local button_addizione = widget.newButton
 
{
  left = 279,
  top = 417 ,
  width = 22 ,
  height = 20,
  defaultFile = ("Sfondi/icons/Group 57.png"),
  overFile = ("Sfondi/icons/Group 57.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone numero 0
local button0 = widget.newButton
 
{ left = 120,
  top = 490 ,
  width = 22,
  height = 54,
  defaultFile = ("Sfondi/icons/0.png"),
  overFile = ("Sfondi/icons/0.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone punto decimale 
local button_decimale = widget.newButton
 
{ left = 210,
  top = 523 ,
  width = 11,
  height = 11,
  defaultFile = ("Sfondi/icons/Ellipse 14.png"),
  overFile = ("Sfondi/icons/Ellipse 14.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone uguale 
local button_uguale = widget.newButton
 
  left = 265,
  top = 494,
  width = 50,
  height = 50 ,
  defaultFile = ("Sfondi/icons/Group 55.png"),
  overFile = ("Sfondi/icons/Group 55.png"),
  onEvent = handleButtonEvent
}
 
-- creazione bottone numero 4 
local button4 = widget.newButton
 
{ left = 35 ,
  top = 330 ,
  width = 22,
  height = 54 ,
  defaultFile = ("Sfondi/icons/4.png"),
  overFile = ("Sfondi/icons/4.png"),
  onEvent = handleButtonEvent
}
 
-- creazione bottone numero 5 
local button5 = widget.newButton
 
{ left = 120,
  top = 330 ,
 width = 22 ,
 height = 54 ,
 defaultFile = ("Sfondi/icons/5.png"),
 overFile = ("Sfondi/icons/4.png"),
 onEvent = handleButtonEvent
}
 
--creazione bottone numero 6 
local button6 = widget.newButton
 
{left = 205,
  top = 330,
  width = 22,
  height = 54,
  defaultFile = ("Sfondi/icons/6.png"),
  overFile = ("Sfondi/icons/6.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone sottrazzione 
 
local button_sottrazione = widget.newButton
 
{
  left = 277,
  top = 348 ,
  width = 27 ,
  height = 4,
  defaultFile = ("Sfondi/icons/Rectangle -2.png"),
  overFile = ("Sfondi/icons/Rectangle -2.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone numero 7 
 
local button7 = widget.newButton
 
{ left = 35,
  top = 260,
  width = 22,
  height = 54,
  defaultFile = ("Sfondi/icons/7.png"),
  overFile = ("Sfondi/icons/7.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone numero 8
 
local button8= widget.newButton
 
{ left = 120,
  top = 260,
  width = 22 ,
  height = 54,
  defaultFile = ("Sfondi/icons/8.png"),
  overFile = ("Sfondi/icons/8.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone numero 9
 
local button9= widget.newButton
 
{
  left = 205 ,
  top = 260 ,
  width = 22 ,
  height = 54,
  defaultFile = ("Sfondi/icons/9.png"),
  overFile = ("Sfondi/icons/9.png"),
  onEvent = handleButtonEvent
}
 
-- creazione bottone moltiplicazione 
 
local button_moltiplicazione = widget.newButton
 
{ left = 278,
  top = 277 ,
  width = 23.38 ,
  height = 23.23,
  defaultFile = ("Sfondi/icons/Group 51.png"),
  overFile = ("Sfondi/icons/Group 51.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone cancella 
button_canc = widget.newButton
 
{ left = 265, 
  top = 207,
  width = 39.51,
  height = 26,
  defaultFile = ("Sfondi/icons/Group 41.png"),
  overFile = ("Sfondi/icons/Group 41.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone percentuale 
 
local button_percentuale = widget.newButton
 
{ left = 207 ,
  top = 207 ,
  width = 21.96 ,
  height = 24.73 ,
  defaultFile = ("Sfondi/icons/Group 49.png"),
  overFile = ("Sfondi/icons/Group 49.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone divisione 
 
local button_divisione = widget.newButton
 
{ left = 119 , 
  top = 208 ,
  width = 25 ,
  height = 20 , 
  defaultFile = ("Sfondi/icons/Group 56.png"),
  overFile = ("Sfondi/icons/Group 56.png"),
  onEvent = handleButtonEvent
}
 
--creazione bottone AC 
 
local button_ac = widget.newButton
 
{ left = 35 ,
  top = 206 ,
  width = 26 , 
  height = 28 , 
  defaultFile = ("Sfondi/icons/AC.png"),
  overFile = ("Sfondi/icons/AC.png"),
  onEvent = handleButtonEvent
}
 
--creazione linea di separazione 
 
local button_linea = widget.newButton
 
{ left = -38,
  top = 150 ,
  width = 360 , 
  height = 1 ,
  defaultFile = ("Sfondi/icons/Line 33.png"),
  overFile = ("Sfondi/icons/Line 33.png"),
 
}
 
--creazione bottone menu home  (menu 1 ) 
 
local button_menuhome = widget.newButton
 
{ left = 105 ,
  top = -55 ,
  width = 27 ,
  height = 22 , 
  defaultFile = ("Sfondi/icons/Group 52.png"),
  overFile = ("Sfondi/icons/Group 52.png"),
  onEvent = handleButtonEvent
}
 
--creazione button menu 2 
 
local button_menu2 = widget.newButton
 
{ left = 205 ,
  top = -57 , 
  width = 26 ,
  height = 26 , 
  defaultFile = ("Sfondi/icons/Group 54.png"),
  overFile = ("Sfondi/icons/Group 54.png"),
  onEvent = handleButtonEvent
}
  
 
 
end
 
 
-- show()
function scene:show( event )
 
    local sceneGroup = self.view
    local phase = event.phase
 
    if ( phase == "will" ) then
        -- Code here runs when the scene is still off screen (but is about to come on screen)
 
    elseif ( phase == "did" ) then
        -- Code here runs when the scene is entirely on screen
 
    end
end
 
 
-- hide()
function scene:hide( event )
 
    local sceneGroup = self.view
    local phase = event.phase
 
    if ( phase == "will" ) then
        -- Code here runs when the scene is on screen (but is about to go off screen)
 
    elseif ( phase == "did" ) then
        -- Code here runs immediately after the scene goes entirely off screen
 
    end
end
 
 
-- destroy()
function scene:destroy( event )
 
    local sceneGroup = self.view
    -- Code here runs prior to the removal of scene's view
 
end
 
 
-- -----------------------------------------------------------------------------------
-- Scene event function listeners
-- -----------------------------------------------------------------------------------
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
-- -----------------------------------------------------------------------------------
 
return scene


[TOPIC: post.html]
#8

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,976 posts
  • Corona SDK

Comment all of your code out and put it back in gradually until you get the error. 



[TOPIC: post.html]
#9

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

Comment all of your code out and put it back in gradually until you get the error. 

yea but my code works perfectly fine on the main.lua i think there something wrong with the composer when it comes to switch the scene to "home2.lua"



[TOPIC: post.html]
#10

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,976 posts
  • Corona SDK

Composer will fail if the scene it is trying to load has a formatting error, and won't necessarily tell you what that error is.

 

Get a blank composer scene working, and gradually add your code in. People don't have time to look through 300 lines of code, and they can't run it because they don't have the images.



[TOPIC: post.html]
#11

jdsmedeirosbr

[GLOBAL: userInfoPane.html]
jdsmedeirosbr
  • Enthusiast

  • 98 posts
  • Corona SDK

yea but my code works perfectly fine on the main.lua i think there something wrong with the composer when it comes to switch the scene to "home2.lua"

 

I tested your code here without the button images and gave no error, are you sure it's the same error?



[TOPIC: post.html]
#12

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

yea i did in the main.lua there was just
Local composer = require ("composer")
composer.gotoScene ("menu2")

And in the menu2.lua there is just the template you guys sent me and in between it sfondo = display.newImageReact ("Sfondi/icons/sfondonero2) and it still doesnt work :/

[TOPIC: post.html]
#13

jdsmedeirosbr

[GLOBAL: userInfoPane.html]
jdsmedeirosbr
  • Enthusiast

  • 98 posts
  • Corona SDK

yea i did in the main.lua there was just
Local composer = require ("composer")
composer.gotoScene ("menu2")

And in the menu2.lua there is just the template you guys sent me and in between it sfondo = display.newImageReact ("Sfondi/icons/sfondonero2) and it still doesnt work :/

 

"Local"???
copy all your main and menu2 code again and put it here, but please, before posting, use the <> format icon to make the code better read.


[TOPIC: post.html]
#14

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

sorry idk what u by <>format, im new to corona amd lua :( btw the menu code is this (main.lua is just local composer = require ("composer")
composer.gotoScene ("menu2")

Menu2:
local composer = require( "composer" )

local scene = composer.newScene()

-- -----------------------------------------------------------------------------------
-- Code outside of the scene event functions below will only be executed ONCE unless
-- the scene is removed entirely (not recycled) via "composer.removeScene()"
-- -----------------------------------------------------------------------------------




-- -----------------------------------------------------------------------------------
-- Scene event functions
-- -----------------------------------------------------------------------------------

-- create()
function scene:create( event )

local sceneGroup = self.view
device_width = display.contentWidth --larghezza in pixel dello schermo del tel
device_height = display.contentHeight --altezza in pixel dello schermo del tel
local coomposer = require ("composer")
--impostazione sfondo
local sfondo = display.newImageRect( "sfondonero.png",device_width,device_height)

sfondo.x= device_width/2
sfondo.y= device_height/2

--richiamo libreria per i widgets
local widget = require("widget")

--funzione che viene richiamata quando il bottone viene premuto quindi quando è nello stato "ended"

local function handleButtonEvent ( event )
local phase = event.phase
if "ended" == event.phase then
print ("Hello World")
end
end

--creazione bottone numero 1
local button1 = widget.newButton

{
left = 35 ,
top = 400 ,
width = 22 ,
height = 54,
defaultFile = ("Sfondi/icons/1.png"),
overFile = ("Sfondi/icons/1.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 2
local button2 = widget.newButton

{
left = 120 ,
top = 400 ,
width = 22 ,
height = 54,
defaultFile = ("Sfondi/icons/2.png"),
overFile = ("Sfondi/icons/2.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 3
local button3 = widget.newButton

{
left = 205 ,
top = 400 ,
width = 22 ,
height = 54,
defaultFile = ("Sfondi/icons/3.png"),
overFile = ("Sfondi/icons/3.png"),
onEvent = handleButtonEvent
}

--creazione bottone addizione
local button_addizione = widget.newButton

{
left = 279,
top = 417 ,
width = 22 ,
height = 20,
defaultFile = ("Sfondi/icons/Group 57.png"),
overFile = ("Sfondi/icons/Group 57.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 0
local button0 = widget.newButton

{ left = 120,
top = 490 ,
width = 22,
height = 54,
defaultFile = ("Sfondi/icons/0.png"),
overFile = ("Sfondi/icons/0.png"),
onEvent = handleButtonEvent
}

--creazione bottone punto decimale
local button_decimale = widget.newButton

{ left = 210,
top = 523 ,
width = 11,
height = 11,
defaultFile = ("Sfondi/icons/Ellipse 14.png"),
overFile = ("Sfondi/icons/Ellipse 14.png"),
onEvent = handleButtonEvent
}

--creazione bottone uguale
local button_uguale = widget.newButton

{
left = 265,
top = 494,
width = 50,
height = 50 ,
defaultFile = ("Sfondi/icons/Group 55.png"),
overFile = ("Sfondi/icons/Group 55.png"),
onEvent = handleButtonEvent
}

-- creazione bottone numero 4
local button4 = widget.newButton

{ left = 35 ,
top = 330 ,
width = 22,
height = 54 ,
defaultFile = ("Sfondi/icons/4.png"),
overFile = ("Sfondi/icons/4.png"),
onEvent = handleButtonEvent
}

-- creazione bottone numero 5
local button5 = widget.newButton

{ left = 120,
top = 330 ,
width = 22 ,
height = 54 ,
defaultFile = ("Sfondi/icons/5.png"),
overFile = ("Sfondi/icons/4.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 6
local button6 = widget.newButton

{left = 205,
top = 330,
width = 22,
height = 54,
defaultFile = ("Sfondi/icons/6.png"),
overFile = ("Sfondi/icons/6.png"),
onEvent = handleButtonEvent
}

--creazione bottone sottrazzione

local button_sottrazione = widget.newButton

{
left = 277,
top = 348 ,
width = 27 ,
height = 4,
defaultFile = ("Sfondi/icons/Rectangle -2.png"),
overFile = ("Sfondi/icons/Rectangle -2.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 7

local button7 = widget.newButton

{ left = 35,
top = 260,
width = 22,
height = 54,
defaultFile = ("Sfondi/icons/7.png"),
overFile = ("Sfondi/icons/7.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 8

local button8= widget.newButton

{ left = 120,
top = 260,
width = 22 ,
height = 54,
defaultFile = ("Sfondi/icons/8.png"),
overFile = ("Sfondi/icons/8.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 9

local button9= widget.newButton

{
left = 205 ,
top = 260 ,
width = 22 ,
height = 54,
defaultFile = ("Sfondi/icons/9.png"),
overFile = ("Sfondi/icons/9.png"),
onEvent = handleButtonEvent
}

-- creazione bottone moltiplicazione

local button_moltiplicazione = widget.newButton

{ left = 278,
top = 277 ,
width = 23.38 ,
height = 23.23,
defaultFile = ("Sfondi/icons/Group 51.png"),
overFile = ("Sfondi/icons/Group 51.png"),
onEvent = handleButtonEvent
}

--creazione bottone cancella
button_canc = widget.newButton

{ left = 265,
top = 207,
width = 39.51,
height = 26,
defaultFile = ("Sfondi/icons/Group 41.png"),
overFile = ("Sfondi/icons/Group 41.png"),
onEvent = handleButtonEvent
}

--creazione bottone percentuale

local button_percentuale = widget.newButton

{ left = 207 ,
top = 207 ,
width = 21.96 ,
height = 24.73 ,
defaultFile = ("Sfondi/icons/Group 49.png"),
overFile = ("Sfondi/icons/Group 49.png"),
onEvent = handleButtonEvent
}

--creazione bottone divisione

local button_divisione = widget.newButton

{ left = 119 ,
top = 208 ,
width = 25 ,
height = 20 ,
defaultFile = ("Sfondi/icons/Group 56.png"),
overFile = ("Sfondi/icons/Group 56.png"),
onEvent = handleButtonEvent
}

--creazione bottone AC

local button_ac = widget.newButton

{ left = 35 ,
top = 206 ,
width = 26 ,
height = 28 ,
defaultFile = ("Sfondi/icons/AC.png"),
overFile = ("Sfondi/icons/AC.png"),
onEvent = handleButtonEvent
}

--creazione linea di separazione

local button_linea = widget.newButton

{ left = -38,
top = 150 ,
width = 360 ,
height = 1 ,
defaultFile = ("Sfondi/icons/Line 33.png"),
overFile = ("Sfondi/icons/Line 33.png"),

}

--creazione bottone menu home (menu 1 )

local button_menuhome = widget.newButton

{ left = 105 ,
top = -55 ,
width = 27 ,
height = 22 ,
defaultFile = ("Sfondi/icons/Group 52.png"),
overFile = ("Sfondi/icons/Group 52.png"),
onEvent = handleButtonEvent
}

--creazione button menu 2

local button_menu2 = widget.newButton

{ left = 205 ,
top = -57 ,
width = 26 ,
height = 26 ,
defaultFile = ("Sfondi/icons/Group 54.png"),
overFile = ("Sfondi/icons/Group 54.png"),
onEvent = handleButtonEvent
}



end


-- show()
function scene:show( event )

local sceneGroup = self.view
local phase = event.phase

if ( phase == "will" ) then
-- Code here runs when the scene is still off screen (but is about to come on screen)

elseif ( phase == "did" ) then
-- Code here runs when the scene is entirely on screen

end
end


-- hide()
function scene:hide( event )

local sceneGroup = self.view
local phase = event.phase

if ( phase == "will" ) then
-- Code here runs when the scene is on screen (but is about to go off screen)

elseif ( phase == "did" ) then
-- Code here runs immediately after the scene goes entirely off screen

end
end


-- destroy()
function scene:destroy( event )

local sceneGroup = self.view
-- Code here runs prior to the removal of scene's view

end


-- -----------------------------------------------------------------------------------
-- Scene event function listeners
-- -----------------------------------------------------------------------------------
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
-- -----------------------------------------------------------------------------------

return scene

[TOPIC: post.html]
#15

jdsmedeirosbr

[GLOBAL: userInfoPane.html]
jdsmedeirosbr
  • Enthusiast

  • 98 posts
  • Corona SDK

sorry idk what u by <>format, im new to corona amd lua :( btw the menu code is this (main.lua is just local composer = require ("composer")
composer.gotoScene ("menu2")

Menu2:
local composer = require( "composer" )

local scene = composer.newScene()

-- -----------------------------------------------------------------------------------
-- Code outside of the scene event functions below will only be executed ONCE unless
-- the scene is removed entirely (not recycled) via "composer.removeScene()"
-- -----------------------------------------------------------------------------------




-- -----------------------------------------------------------------------------------
-- Scene event functions
-- -----------------------------------------------------------------------------------

-- create()
function scene:create( event )

local sceneGroup = self.view
device_width = display.contentWidth --larghezza in pixel dello schermo del tel
device_height = display.contentHeight --altezza in pixel dello schermo del tel
local coomposer = require ("composer")
--impostazione sfondo
local sfondo = display.newImageRect( "sfondonero.png",device_width,device_height)

sfondo.x= device_width/2
sfondo.y= device_height/2

--richiamo libreria per i widgets
local widget = require("widget")

--funzione che viene richiamata quando il bottone viene premuto quindi quando è nello stato "ended"

local function handleButtonEvent ( event )
local phase = event.phase
if "ended" == event.phase then
print ("Hello World")
end
end

--creazione bottone numero 1
local button1 = widget.newButton

{
left = 35 ,
top = 400 ,
width = 22 ,
height = 54,
defaultFile = ("Sfondi/icons/1.png"),
overFile = ("Sfondi/icons/1.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 2
local button2 = widget.newButton

{
left = 120 ,
top = 400 ,
width = 22 ,
height = 54,
defaultFile = ("Sfondi/icons/2.png"),
overFile = ("Sfondi/icons/2.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 3
local button3 = widget.newButton

{
left = 205 ,
top = 400 ,
width = 22 ,
height = 54,
defaultFile = ("Sfondi/icons/3.png"),
overFile = ("Sfondi/icons/3.png"),
onEvent = handleButtonEvent
}

--creazione bottone addizione
local button_addizione = widget.newButton

{
left = 279,
top = 417 ,
width = 22 ,
height = 20,
defaultFile = ("Sfondi/icons/Group 57.png"),
overFile = ("Sfondi/icons/Group 57.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 0
local button0 = widget.newButton

{ left = 120,
top = 490 ,
width = 22,
height = 54,
defaultFile = ("Sfondi/icons/0.png"),
overFile = ("Sfondi/icons/0.png"),
onEvent = handleButtonEvent
}

--creazione bottone punto decimale
local button_decimale = widget.newButton

{ left = 210,
top = 523 ,
width = 11,
height = 11,
defaultFile = ("Sfondi/icons/Ellipse 14.png"),
overFile = ("Sfondi/icons/Ellipse 14.png"),
onEvent = handleButtonEvent
}

--creazione bottone uguale
local button_uguale = widget.newButton

{
left = 265,
top = 494,
width = 50,
height = 50 ,
defaultFile = ("Sfondi/icons/Group 55.png"),
overFile = ("Sfondi/icons/Group 55.png"),
onEvent = handleButtonEvent
}

-- creazione bottone numero 4
local button4 = widget.newButton

{ left = 35 ,
top = 330 ,
width = 22,
height = 54 ,
defaultFile = ("Sfondi/icons/4.png"),
overFile = ("Sfondi/icons/4.png"),
onEvent = handleButtonEvent
}

-- creazione bottone numero 5
local button5 = widget.newButton

{ left = 120,
top = 330 ,
width = 22 ,
height = 54 ,
defaultFile = ("Sfondi/icons/5.png"),
overFile = ("Sfondi/icons/4.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 6
local button6 = widget.newButton

{left = 205,
top = 330,
width = 22,
height = 54,
defaultFile = ("Sfondi/icons/6.png"),
overFile = ("Sfondi/icons/6.png"),
onEvent = handleButtonEvent
}

--creazione bottone sottrazzione

local button_sottrazione = widget.newButton

{
left = 277,
top = 348 ,
width = 27 ,
height = 4,
defaultFile = ("Sfondi/icons/Rectangle -2.png"),
overFile = ("Sfondi/icons/Rectangle -2.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 7

local button7 = widget.newButton

{ left = 35,
top = 260,
width = 22,
height = 54,
defaultFile = ("Sfondi/icons/7.png"),
overFile = ("Sfondi/icons/7.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 8

local button8= widget.newButton

{ left = 120,
top = 260,
width = 22 ,
height = 54,
defaultFile = ("Sfondi/icons/8.png"),
overFile = ("Sfondi/icons/8.png"),
onEvent = handleButtonEvent
}

--creazione bottone numero 9

local button9= widget.newButton

{
left = 205 ,
top = 260 ,
width = 22 ,
height = 54,
defaultFile = ("Sfondi/icons/9.png"),
overFile = ("Sfondi/icons/9.png"),
onEvent = handleButtonEvent
}

-- creazione bottone moltiplicazione

local button_moltiplicazione = widget.newButton

{ left = 278,
top = 277 ,
width = 23.38 ,
height = 23.23,
defaultFile = ("Sfondi/icons/Group 51.png"),
overFile = ("Sfondi/icons/Group 51.png"),
onEvent = handleButtonEvent
}

--creazione bottone cancella
button_canc = widget.newButton

{ left = 265,
top = 207,
width = 39.51,
height = 26,
defaultFile = ("Sfondi/icons/Group 41.png"),
overFile = ("Sfondi/icons/Group 41.png"),
onEvent = handleButtonEvent
}

--creazione bottone percentuale

local button_percentuale = widget.newButton

{ left = 207 ,
top = 207 ,
width = 21.96 ,
height = 24.73 ,
defaultFile = ("Sfondi/icons/Group 49.png"),
overFile = ("Sfondi/icons/Group 49.png"),
onEvent = handleButtonEvent
}

--creazione bottone divisione

local button_divisione = widget.newButton

{ left = 119 ,
top = 208 ,
width = 25 ,
height = 20 ,
defaultFile = ("Sfondi/icons/Group 56.png"),
overFile = ("Sfondi/icons/Group 56.png"),
onEvent = handleButtonEvent
}

--creazione bottone AC

local button_ac = widget.newButton

{ left = 35 ,
top = 206 ,
width = 26 ,
height = 28 ,
defaultFile = ("Sfondi/icons/AC.png"),
overFile = ("Sfondi/icons/AC.png"),
onEvent = handleButtonEvent
}

--creazione linea di separazione

local button_linea = widget.newButton

{ left = -38,
top = 150 ,
width = 360 ,
height = 1 ,
defaultFile = ("Sfondi/icons/Line 33.png"),
overFile = ("Sfondi/icons/Line 33.png"),

}

--creazione bottone menu home (menu 1 )

local button_menuhome = widget.newButton

{ left = 105 ,
top = -55 ,
width = 27 ,
height = 22 ,
defaultFile = ("Sfondi/icons/Group 52.png"),
overFile = ("Sfondi/icons/Group 52.png"),
onEvent = handleButtonEvent
}

--creazione button menu 2

local button_menu2 = widget.newButton

{ left = 205 ,
top = -57 ,
width = 26 ,
height = 26 ,
defaultFile = ("Sfondi/icons/Group 54.png"),
overFile = ("Sfondi/icons/Group 54.png"),
onEvent = handleButtonEvent
}



end


-- show()
function scene:show( event )

local sceneGroup = self.view
local phase = event.phase

if ( phase == "will" ) then
-- Code here runs when the scene is still off screen (but is about to come on screen)

elseif ( phase == "did" ) then
-- Code here runs when the scene is entirely on screen

end
end


-- hide()
function scene:hide( event )

local sceneGroup = self.view
local phase = event.phase

if ( phase == "will" ) then
-- Code here runs when the scene is on screen (but is about to go off screen)

elseif ( phase == "did" ) then
-- Code here runs immediately after the scene goes entirely off screen

end
end


-- destroy()
function scene:destroy( event )

local sceneGroup = self.view
-- Code here runs prior to the removal of scene's view

end


-- -----------------------------------------------------------------------------------
-- Scene event function listeners
-- -----------------------------------------------------------------------------------
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
-- -----------------------------------------------------------------------------------

return scene

 

When you type here in the forum, before posting, you have a button with this symbol <> on the top of the text field, select your entered code and click this icon to format your code at the time you click post.
 
What error message is appearing?

Your code is apparently correct! Are the main.lua and menu2.lua files in the same directory as folders? Is the filename menu2.lua spelled the same as you typed in the code?


[TOPIC: post.html]
#16

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

first of all tysm and yes main and menu2 are in the same folder, the files name its 'menu2.lua' and its spelled correctly in the main :/

[TOPIC: post.html]
#17

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

the error says that im trying to give the 'namescene' (in composer.gotoScene ("menu2") a nil value :/

[TOPIC: post.html]
#18

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,976 posts
  • Corona SDK

Can you try what I suggested? Get a blank composer template, call it menu2.lua, and see if it works. Then you know it's your code. 

 

That error may be a red-herring, as I said if it tries to load a scene and it can't parse the Lua it will throw an error before it even starts running the code in the scene.



[TOPIC: post.html]
#19

jdsmedeirosbr

[GLOBAL: userInfoPane.html]
jdsmedeirosbr
  • Enthusiast

  • 98 posts
  • Corona SDK

the error says that im trying to give the 'namescene' (in composer.gotoScene ("menu2") a nil value :/

 

What code editor are you using?



[TOPIC: post.html]
#20

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

What code editor are you using?

ZeroBrane

 

Can you try what I suggested? Get a blank composer template, call it menu2.lua, and see if it works. Then you know it's your code. 

 

That error may be a red-herring, as I said if it tries to load a scene and it can't parse the Lua it will throw an error before it even starts running the code in the scene.

i tried and it composer works if on "home2" there aren't lines of code, but as soon as i try to add a the change scene templete it gives me this error https://gyazo.com/e40f0fdd40248e85d007224237ca7ea6



[TOPIC: post.html]
#21

jdsmedeirosbr

[GLOBAL: userInfoPane.html]
jdsmedeirosbr
  • Enthusiast

  • 98 posts
  • Corona SDK

ZeroBrane

 

i tried and it composer works if on "home2" there aren't lines of code, but as soon as i try to add a the change scene templete it gives me this error https://gyazo.com/e40f0fdd40248e85d007224237ca7ea6

 

In Zerobrane have you adjusted this setting? Project > lua interpreter > Corona


  • filippo66627 likes this

[TOPIC: post.html]
#22

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

yea i did :/
  • filippo66627 likes this

[TOPIC: post.html]
#23

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,976 posts
  • Corona SDK

ZeroBrane

 

i tried and it composer works if on "home2" there aren't lines of code, but as soon as i try to add a the change scene templete it gives me this error https://gyazo.com/e40f0fdd40248e85d007224237ca7ea6

 

Where has 'home2' come from?



[TOPIC: post.html]
#24

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

Where has 'home2' come from?

"menu2" sorry

[TOPIC: post.html]
#25

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

In Zerobrane have you adjusted this setting? Project > lua interpreter > Corona

first thing i did when i installed zerobrane


[topic_controls]
Page 1 of 3 1 2 3
 
[/topic_controls]