hi,
I have followed the documentation about the access of value from another scene :
https://docs.coronalabs.com/guide/system/composer/index.html
But i receive a nill value in my menu.lua when i print(params.someKey), it’s the data of my game.lua. I put this print() in my scene:show. normaly i should receive the return : 1.
what i do wrong ? Thanks for your assist.
a part of my game.lua
local composer = require( "composer" ) local scene = composer.newScene() local background={} local circle={} local count=1 local options = { effect="slideRight", time=1000, params = { someKey=count, someOtherKey=2 } } local function randomSide() sidex=math.random(0,500) sidey=math.random(0,500) end local function displacement() count=count+1 print("displacement",count) circle:setFillColor(0,0,0) randomSide() local function displacement2() transition.to(circle,{time=2000, x=sidex, y=sidey, onComplete=displacement}) end displacement2() end --------------------------------------------------------------------------------- -- All code outside of the listener functions will only be executed ONCE -- unless "composer.removeScene()" is called. --------------------------------------------------------------------------------- -- local forward references should go here --------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view background=display.newRect(0,0,5000,5000) background:setFillColor(1,1,1) sceneGroup:insert(background) circle = display.newCircle(display.contentWidth\*.5,display.contentHeight\*.5,50) circle:setFillColor(1,0,0) sceneGroup:insert(circle) timer.performWithDelay(2000,displacement) local function handleButtonEvent( event ) if ( "ended" == event.phase ) then print( "Button was pressed and released" ) composer.gotoScene( "menu", options ) end end ..............
and my menu.lua
local composer = require( "composer" ) local scene = composer.newScene() local widget = require("widget") ..... function scene:show( event ) local sceneGroup = self.view local phase = event.phase local params = event.phase if ( phase == "will" ) then -- Called when the scene is still off screen (but is about to come on screen). print(params.someKey) elseif ( phase == "did" ) then -- Called when the scene is now on screen. -- Insert code here to make the scene come alive. -- Example: start timers, begin animation, play audio, etc. end end ...........