The scene’s of my game flows as follows: main.lua ----menu.lua—levelTracker.lua—level1.lua or level2.lua etc.
I also have:
score.lua (table for storing the score for each level.
mode.lua (a table storing 0 or 1 to activate a level with 1 meaning active)
star.lua (a table showing that stores the number of stars for each level based on the players score).
When I start out, I press the play game button at the menu screen which takes me to levelTracker. At levelTracker.lua I can press the active level buttons and it takes me to that level of game play.
Problem: The purpose of the loadStars function is to pull the number of stars that should be displayed for a level that is active. By default if a level is not active there are not stars to be retrieved. In levelTracker.lua, I’m loading the number of stars applicable to the level from star.lua, Also, I have the display object for stars set up with an Alpha = 0 in the Create Scene section. But the stars are not displaying on the screen even after I change the alpha to 1 in the loadStars function.
Its as if the code for loadStars() is never being triggered to start once I get to levelTracker.lua from menu lua. I need the stars just appear without any action such as a button being pressed.
Here is my code for level one which is an active level:
local function loadStars()
if starL1 == 1 then
oneStar.x = 70; oneStar.y = 365
oneStar.alpha = 1
elseif starL1 == 2 then
oneStar.x = 70; oneStar.y = 365
oneStar.alpha = 1
twoStar.x=95; twoStar.y=365
twoStar.alpha = 1
elseif smileyFaceL1 == 3 then
oneStar.x = 70; oneStar.y = 365
oneStar.alpha = 1
twoStar.x=95; twoStar.y=365
twoStar.alpha = 1
threeStar.x = 120; threeStar.y = 365
threeStar.alpha = 1
end
end
Question:
What should I do to make the levelTracker.lua perform the star function? Among other things, I’ve tried a runtime - enterFrame but it goes haywire and goes on endlessly.
(I only have one star PNG so right now I have multiple lines to get to three stars)
I appreciate any help!!