Step 1: I’m in scene A.
This has 2 objects which are FirstObjOfA and SecondObjOfA.
When the scene is created, the FirstObjOfA is added to the scene.
Step 2: On tapping a button inside FirstObjOfA, an event is dispatched to the parent (Scene A) and SecondObjOfA is opened with some specific parameters.
Something like this:
local function sceneAEventListener(event)
if ( event.type == ‘gotoSecondObjOfA’) then
FirstObjOfA:removeSelf();
FirstObjOfA = nil;
SecondObjOfA = SecondObject.new(params)
sceneGroup:insert(SecondObjOfA);
end
Runtime:addEventListener(‘sceneA’, sceneAEventListener);
Step 3: Now on tapping of SecondObjOfA an event is dispatched to the parent where the scene is now changed (say Scene B). And Scene A is destroyed.
Step 4: In Scene B, there’s some action performed that calls ‘Scene A’. FirstObjOfA gets loaded with fresh parameters.
Step 5: On tapping a button in it, ideally SecondObjOfA should open with fresh parameters, just like in Step 2, but now the code inside sceneAEventListener with event.type == ‘gotoSecondObjOfA’ runs twice.
First with the earlier parameters passed in step 2 now again with the new parameters and there are two objects that get created.
Any idea what’s wrong? And why is the first parameters loading again.