crystal.Scene

Game state or level which can draw to the screen. Crystal keeps track of the currently active scene and forwards LÖVE callbacks (update, draw, etc.) to it.

This class is of little use on its own. You should implement subclasses fitting your game and override some of the callbacks.

Constructor

crystal.Scene:new()

Callbacks

Name Description
action_pressed Called from love.update when a player presses a key or button bound to an action.
action_released Called from love.update when a player releases a key or button bound to an action.
draw Called every frame from love.draw.
gamepad_pressed Called from love.gamepadpressed.
gamepad_released Called from love.gamepadreleased.
key_pressed Called from love.keypressed.
key_released Called from love.keyreleased.
mouse_moved Called from love.mousemoved.
mouse_pressed Called from love.mousepressed.
mouse_released Called from love.mousereleased.
update Called every frame from love.update.

Examples

local TitleScreen = Class("TitleScreen", crystal.Scene);

TitleScreen.draw = function(self)
  love.graphics.print("Legend of Sword", 100, 100);
end

TitleScreen.key_pressed = function(self)
  crystal.scene.replace(
  MyGameScene:new(),
    crystal.Transition.FadeToBlack:new(),
    crystal.Transition.FadeFromBlack:new()
  );
end

This site uses Just the Docs, a documentation theme for Jekyll.