-
Notifications
You must be signed in to change notification settings - Fork 0
Scenes
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.
novum lets you discover scenes automatically using novum:discoverAll Scenes. it will find everything in the game's scenes folder and import every lua file that doesn't start with _.
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:load(game)scene:update(game, dt)scene:draw(game)scene:keypressed(game, key)scene:keyreleased(game, key)scene:touchpressed(game, id, x, y, dx, dy, pressure)scene:touchmoved(game, id, x, y, dx, dy, pressure)scene:touchreleased(game, id, x, y, dx, dy, pressure)
in addition, novum has custom callbacks:
-
scene:opened(game, data)is called as soon as a scene is switched to (after any possible transitions finish).