Off-topic: @Codeabin use an @ before someone’s username such as: @ExampleUsername to notify them when you say something. (Note: doesn’t notify if you added it via an edit)
@SkyTheCoder I’m using the code he posted above with @Ignatz change. I added a setup() and draw() function to use the class and it works until switchTimer reaches 120. So that’s why I asked what he was getting that didn’t work. He said he made the change too.
-- Original code from Brainfox, off the Codea forums
Scene = {}
local scenes = {}
local sceneNames = {}
local currentScene = nil
setmetatable(Scene,{__call = function(_,name,cls)
if (not currentScene) then
currentScene = 1
end
table.insert(scenes,cls)
sceneNames[name] = #scenes
Scene_Select = nil
end})
--Change scene
Scene.Change = function(name)
currentScene = sceneNames[name]
scenes[currentScene]:init()
if (Scene_Select) then
Scene_Select = currentScene
end
collectgarbage()
end
Scene.Draw = function()
pushStyle()
pushMatrix()
scenes[currentScene]:draw()
popMatrix()
popStyle()
end
Scene.Touched = function(t)
if (scenes[currentScene].touched) then
scenes[currentScene]:touched(t)
end
end
Scene.Keyboard = function()
if (scenes[currentScene].keyboard) then
scenes[currentScene]:keyboard(key)
end
end
Scene.OrientationChanged = function()
if (scenes[currentScene].orientationChanged) then
scenes[currentScene]:orientationChanged()
end
end