So I have a question that seems to be eluding me. I am trying to pass variables between scenes, more specifically a score. Here’s some pseudocode:
On the levelSelection.lua scene, the list of levels are here to choose from. There is a highScore variable set for each one of these levels, set to 0. In level1.lua a variable “score” is created. Once the level objective is completed, I would like to pass “score” from level1.lua, back to levelSelection.lua and update the level1 highScore variable there.
Here’s what I was thinking:
[lua]–levelSelection.lua
_G.level1HighScore = 0;
testText = display.newText (level1HighScore, 140, 300, “Arial”, 20)
–level1.lua
score = 100;
levelSelection.level1HighScore = score;[/lua]
Something like that. (I hope this is not too broad). This does not work though and it does not update. I think it is because every time I run the levelSelection.lua scene, it resets level1HighScore to 0. Can anyone help me out? Thanks in advance! [import]uid: 50511 topic_id: 24879 reply_id: 324879[/import]
