Skip to content
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...).

novum functions

novum:switchSceneInstant(name)

switches to the specified scene instantly

novum:switchSceneByTransition(name, transition, duration)

switches to the specified scene instantly

novum:discoverScene(name)

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.

defining a scene

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 Scene

you 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 Scene

implemented callbacks

novum 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)

Clone this wiki locally