I don’t seem to have an obvious enterScene & createScene, they might be in Storyboard or something?
I use the Director Class (Haha, I hope that’s not outdated or anything.)
My .lua file basically looks like this (Shortened):
module(..., package.seeall); function new() local localGroup = display.newGroup(); --CONTENT CREATION SECTION-- local UnBuildable= display.newImageRect("Images/UnBuildable.png", 150, 100); UnBuildable:setReferencePoint(display.TopLeftReferencePoint); UnBuildable.x = 460; UnBuildable.y = 188; if unitData:retrieve("TrainingProgress") == 1 then --Show image or not? UnBuildable.isVisible = true; else UnBuildable.isVisible = false; end --BUTTON PRESS AND TIMER FUNCTIONS-- local function unitBuilt() -- Makes function for completion of timer. print(Data[unitProgressData].name .. " Unit Trained") --print check unitData:store("TrainingProgress", 0); --Allows reuse of button. unitData:save() UnBuildable.isVisible = false; -- timer completed, changes visibility off. end local function unitBuild(e) -- function for pressing of button to begin timer. if(e.phase == "ended" and (unitData:retrieve("TrainingProgress")) == 0) then UnBuildable.isVisible = true;--turn on image visibility timer.performWithDelay( 6000, unitBuilt, 1 ) --6 second timer unitData:store("TrainingProgress", 1); -- Stops reuse of button. unitData:save() end end buttonBuild:addEventListener("touch", unitBuild); return localGroup; end
So, when I leave and come back, it’ll create the image again it all again.
So in the unitBuilt function, UnBuildable.isVisible doesn’t seem to find the new UnBuildable that was re-made and associate with it.
Does that help?