Composer not passing parameters to the scene for the 2nd time

Well I have not used the composer yet but it should be about the same as storyboard. They just shuffled the events a bit. I’m thinking that this is a code setup problem especially because of your last statement. Make sure you are doing this in this way:

nothing except module initialization outside of scene events

  • create - create display objects and alike

  • show - check the phase as it’s called twice on phase “will” positions object for reset and alike on phase “did” start transitions, timers, audio, …

  • hide - check phase again it’s called twice on phase “will” stop transition, timers, network requests, remove enterFrame events, stop audio, … on phase “did” you should not have to do anything here except clean up of loaded resources than need to be released explicitly that you may have loaded in show

  • destroy - you should not have to do anything here except clean up of loaded resources than need to be released explicitly that you may have loaded in create

Make sure all display objects you create for the scene are inserted in the scene.view.

Hope this gives you a clue.

Krystian can you put together a sample that shows this?

Thanks

Rob

Sure,

please find the attached examples.(file uploads don’t work, here’s a link: https://www.dropbox.com/s/3np60wz3zq40cnl/composerIssue.zip )

There are 3 tests, just uncomment the lines in main.lua.

Thanks

First you are making a lot of jumps from one file to the other. Not sure why.

There are two problems in your code.

  1. You can not remove the current scene

  2. If you call gotoScene and the scene is already created (has not been removed) then the create will not be called.

Try this in your main.lua and you will see it works fine:

local composer = require("composer") local test1 = require("test1") --loads the module and goes to scene "s" timer.performWithDelay(1000, function() print("goto s2"); composer.gotoScene("s2") end) -- changes scene so we can remove "s" timer.performWithDelay(2000, function() print("remove s"); composer.removeScene("s") end) -- now remove "s" timer.performWithDelay(3000, function() local test2 = require("test2") end) --load "s" again and go to it

I hope this helps.

primoz.cerar: not really. what you pasted, is what my test3 does.

Why am I not able to remove current scene? What’s the problem with that?

Besides, as you can see in my test2, I can remove current scene.

Unfortunately, then I’m unable to pass any parameters to it, when it’s recreated - I believe this is a bug.

I am trying this with storyboard but it should work exactly the same. Your code doesn’t work with storyboard either.

If you have this in your main.lua:

local test1 = require(“test1”) – this will create and go to “s”
local test2 = require(“test2”) – this will do the same thing again

–local test3 = require(“test3”) – leave commented out

you will see that create scene in which you have this:

print(“scene create”)

will be called only once.

Because the scene has not been removed and in test2 you call composer.gotoScene(“s”, { params = { config = 12345 } })  again. This actually does nothing as “s” is the current scene.

As for removing current scene as far as I know you can call removeScene for current scene but it won’t do anything.

I’ve just tested this. If you remove the gotoScene(“s2”) line from the code I posted above than the create scene doesn’t get called again so it did not remove it. If you put gotoScene(“s2”) back in then create scene will be called again. Check the print statements in the terminal window.

These tests are not meant to be ran together.

Uncomment only single one of them please. 

Understood. But my previous point still holds. You can not remove the current scene. That’s why in test2 the create scene in “s” doesn’t get called the second time as it was the current scene when you were trying to remove it.

In test2, scene’s “s” create function is called for the second time, but without the parameters passed in the goto call.

Will check again. When I get home. Just to clarify and make sure it works same with storyboard or is an actual bug:

This is from “s” create:

    print(“scene create”)
    if event and event.name then print(“event.name”, event.name) end

With test2 do you see this printed twice or only once?

Actualy please post the terminal output you get with test2 that way I can be sure what is going on.

primoz, thanks for the help, but do tell, what’s the point on comparing how something worked in storyboard vs composer, if I am trying to confirm a bug in composer?

It’s like comparing behavior of transitions v1 with transitions v2, when v2 looks to have more bugs than code lines [just kidding, only counted 1]

Well I’m trying to get you going and as Composer is just a minor rework of the scene events it should function exactly the same. As I mentioned before your code would not function in storyboard and thus I’m deducting that it will not function in composer as well. The print from terminal will tell me all I need to know.

If you wish to wait for someone else to help that’s up to you.

primoz: thanks, as you saw in one of the tests, I’ve got a valid workaround on this issue, I’m just trying to get someone from Corona to tell me whether they consider it a bug or not. If they do I’ll just raise a bug and if not, there’s no point in wasting mine nor their analyst’s time :slight_smile:

Hi there,

Today I encountered the same issue as krystian : when doing a storyboaord.gotoscene( “scene1”, options ) ; with parameters, the behaviour is not the same if you were already on the scene1 or not.

To put it simply : when you do a gotoscene( “scene1”, options ) while already being in the scene1, it will work but the params in options won’t be passed.

Minimalist example of the bug -> https://www.dropbox.com/s/ze0m7h347fu9066/test.zip

Okay.  I looked at it, looks like a bug to me.  Can I get you to file a bug report using the “Report a bug” link above. 

When you get the email back from the bug tracker, post the number here as a reference.

Thanks

Rob

Hello,

  any news on this bug? I’ve the same problem.

Thanks in advance.

Hi,

I had the same problem, so I’ve switched to “myData” kind of data passing.

Now it works like a charm.

Example:

mydata.lua:

local M = {}

return M

file1.lua:

local myData = require( “mydata” )

myData.variable=25

composer.gotoScene( “file2”, “crossFade” )

file2.lua:

local myData = require( “mydata” )

print(myData.variable)

Best regards!

Hello,

  any news on this bug? I’ve the same problem.

Thanks in advance.

I currently have the same issue.

event.params is nil if you attempt to go to the scene you are already on and pass params in the options.

Has there been a bug report filed for this? If so, can the filer post the # here so I can check its status?

Thanks,

Brent