love

When beginning to write games using LÖVE, the most important parts of the API are the callbacks: love.load to do one-time setup of your game, love.update which is used to manage your game's state frame-to-frame, and love.draw which is used to render the game state onto the screen.

More interactive games will override additional callbacks in order to handle input from the user, and other aspects of a full-featured game.

LÖVE provides default placeholders for these callbacks, which you can override inside your own code, simply by specifying their fully qualified name:

-- Load some default values for our rectangle.
function love.load()
    x, y, w, h = 20, 20, 60, 20;
end

-- Increase the size of the rectangle every frame.
function love.update(dt)
    w = w + 1;
    h = h + 1;
end

-- Draw a coloured rectangle.
function love.draw()
    love.graphics.setColor(0, 100, 100);
    love.graphics.rectangle('fill', x, y, w, h);
end

LÖVE also includes third party modules:

Modules

love.audioProvides an interface to output sound to the user's speakers.
love.eventManages events, like keypresses.
love.filesystemProvides an interface to the user's filesystem.
love.fontAllows you to work with fonts.Added since 0.7.0
love.graphicsDrawing of shapes and images, management of screen geometry.
love.imageProvides an interface to decode encoded image data.
love.joystickProvides an interface to connected joysticks.
love.keyboardProvides an interface to the user's keyboard.
love.mathProvides system-independent mathematical functions.Added since 0.9.0
love.mouseProvides an interface to the user's mouse.
love.physicsCan simulate 2D rigid body physics in a realistic manner.
love.soundThis module is responsible for decoding sound files.
love.systemProvides access to information about the user's system.Added since 0.9.0
love.threadAllows you to work with threads.Added since 0.7.0
love.timerProvides an interface to your system's clock.
love.windowProvides an interface for the program's window.Added since 0.9.0

Functions

love.getVersionGets the current running version of LÖVE.Added since 0.9.1

Types

DataThe superclass of all data.
ObjectThe superclass of all LÖVE types.

Callbacks

General

Config FilesGame configuration settings.
love.drawCallback function used to draw on the screen every frame.
love.errhandThe error handler, used to display error messages.
love.focusCallback function triggered when window receives or loses focus.Added since 0.7.0
love.keypressedCallback function triggered when a key is pressed.
love.keyreleasedCallback function triggered when a key is released.
love.loadThis function is called exactly once at the beginning of the game.
love.mousefocusCallback function triggered when window receives or loses mouse focus.Added since 0.9.0
love.mousepressedCallback function triggered when a mouse button is pressed.
love.mousereleasedCallback function triggered when a mouse button is released.
love.quitCallback function triggered when the game is closed.Added since 0.7.0
love.resizeCalled when the window is resized.Added since 0.9.0
love.runThe main function, containing the main loop. A sensible default is used when left out.
love.textinputCalled when text has been entered by the user.Added since 0.9.0
love.threaderrorCallback function triggered when a Thread encounters an error.Added since 0.9.0
love.updateCallback function used to update the state of the game every frame.
love.visibleCallback function triggered when window is shown or hidden.Added since 0.9.0

Joystick

love.gamepadaxisCalled when a Joystick's virtual gamepad axis is moved.Added since 0.9.0
love.gamepadpressedCalled when a Joystick's virtual gamepad button is pressed.Added since 0.9.0
love.gamepadreleasedCalled when a Joystick's virtual gamepad button is released.Added since 0.9.0
love.joystickaddedCalled when a Joystick is connected.Added since 0.9.0
love.joystickaxisCalled when a joystick axis moves.Added since 0.9.0
love.joystickhatCalled when a joystick hat direction changes.Added since 0.9.0
love.joystickpressedCalled when a joystick button is pressed.
love.joystickreleasedCalled when a joystick button is released.
love.joystickremovedCalled when a Joystick is disconnected.Added since 0.9.0


Other Languages

Personal tools