Greetings,
This is a little long …I’ll try to summarize and simplify as much as possible:
I have scene that calls an overlay. In that overlay is a menu of sorts, and I have a declaration of variables at top. yada yada yada…
I’m using a lock system for certain items that you can do a ‘shortcut unlock’ by watching a video (incentivized adverts). To keep track of which locked items are being hit, I’m using something like this to keep track of them, ‘item[i].id = i’.
One of the declarations at the top I’m using is an unlock number variable, ‘unlockNum=1’ for default value.
When the user touches one of the locks - it finds the ‘.id’ of the item that’s being touched, and then I do ‘unlockNum = id’. Simple enough.
The advertisement then launches - and in the adListener function , once the user closes the advertisement - I use the unlockNum to figure out which item it just unlocked.
ALL IS FINE if the user is in the overlay for the first time. I DO NOT DESTROY the overlay, but I Hide it once user is ready to move on.
Then when the user goes to the overlay (the menu) a second time, third, etc. - and the user tries to click on another lock - The advertisement launches but the ‘unlockNum’ value doesn’t change to the ‘.id’ when I fetch it in the ‘adListener’ function. If I was in the overlay for first time - then it does change value as expected.
*** I’ve been using ‘print’ statements to help me debug… and it seems that during the second,third,etc. time user goes to the Overlay - On the touch function (just before the advertisement launches, but still in touch function) - I print( unlockNum ) and the value is reporting correctly (to the item.id). Then I have a ‘print’ statement in adListener function when it completes, and use print( unlockNum ) and it’s reporting the ‘unlockNum’ value from the first time user is in the overlay (an older value)… HUH???
I’m a bit lost, because the value is correctly updating on the ‘touch event’ but when the advertisement completes, and the adListener gets called, the value is showing the old value from when user was in the Overlay scene for first time… When the user is in the overlay scene for first time, then everything works as expected… ??? HELP!