-
Notifications
You must be signed in to change notification settings - Fork 0
Scenes
Mizu edited this page Apr 24, 2023
·
2 revisions
scenes are a core concept of novum. a game should be composed of multiple scenes (for example, the mandatory initial scene, a scene for the level selection, a scene that handles the gameplay...).
switches to the specified scene instantly
switches to the specified scene instantly
creates a new scene with the specified name. there should be a file in scenes/name.lua where name is the specified name.
novum automatically discovers the initial scene (scenes/initial.lua) and switches to it when the game starts.
here's how a scene file should be structured:
local Scene = {
-- data
foo = 'bar',
spam = 'eggs',
one = function(self) return 1 end,
-- callbacks
update = function(self, game, dt) ... end,
draw = function(self, game) ... end,
}
return Sceneyou may also do:
local Scene = {}
-- data
Scene.foo = 'bar'
Scene.spam = 'eggs'
function Scene:one()
return 1
end
-- callbacks
function Scene:update(game, dt) ... end
function Scene:draw(game) ... end
return Scenenovum has implemented the following LÖVE callbacks (note: game is the novum framework):
scene:update(game, dt)scene:draw(game)scene:keypressed(game, key)scene:keyreleased(game, key)