From 1abc19e89ace03fed756f948a62f163a041b889a Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Fri, 13 Aug 2010 14:29:25 +0200 Subject: [PATCH] Finished documentation porting --- index.html | 127 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 89 insertions(+), 38 deletions(-) diff --git a/index.html b/index.html index d439319..ae1f9fd 100644 --- a/index.html +++ b/index.html @@ -384,9 +384,9 @@ result:foo() -- error: method does not exist - + - +
Parameters:[optional vector]pos: Initial position of the camera. Defaults to (0,0).
[optional number]zoom:
[optional number]zoom: Initial zoom. Defaults to 1.
[optional number]rotation:
[optional number]rotation: Initial rotation in radians. Defaults to 0.
Returns:a new camera object
@@ -446,52 +446,103 @@ camera:deapply()

gamestate.lua^ top

- Useful to separate different states of your game (hence "gamestate") like title screens, level loading, main game, etc. Each gamestate can have it's own update(), draw(), keyreleased(), keypressed() and mousereleased() which correspond to the ones defined in love. +

Useful to separate different states of your game (hence "gamestate") like title screens, + level loading, main game, etc. Each gamestate can have it's own update(), draw(), + keyreleased(), keypressed() and mousereleased() which correspond + to the ones defined in love. See the callback list for more details.

- Additionally, each gamestate can define a enter and leave function, which are called when using Gamestate.switch. See below. - function Gamestate.new() +

Additionally, each gamestate can define a enter(pre, ...) and leave() function, + which are called when using Gamestate.switch(to, ...). Do not attempt to use these functions + yourself to initialize the first gamestate, use the switch function instead.

- Create a new gamestate. - Returns: The new (but empty) gamestate object. - function Gamestate.switch(to, ...) +

The module defines the following functions: + + + + + + + + + +
Gamestate.new()New gamestate
Gamestate.switch(to, ...)Switch gamestate
Gamestate.update(dt)Call update callback
Gamestate.draw()Call draw callback
Gamestate.keypressed(key, unicode)Call keypressed callback
Gamestate.keyreleased(key)Call keyreleased callback
Gamestate.mousereleased(x,y,btn)Call mousereleased callback
Gamestate.registerEvents()Register all callbacks

- Switch the gamestate. - Calls leave on the currently active gamestate. - Calls enter(current, ...) on the target gamestate, where current is the gamestate before the switch and ... are the additionals arguments given to Gamestate.switch. - Parameters: * [gamestate] to: The target gamestate. * ...: Additional arguments to pass + +
function Gamestate.new()^ top + Create a new gamestate. +
Returns:The new (but empty) gamestate object.
+
- Returns: the result of to:enter(current, ...) + +
function Gamestate.switch(to, ...)^ top + Switch the gamestate. +

Calls leave() on the currently active gamestate.

+

Calls enter(current, ...) on the target gamestate, where current + is the gamestate before the switch and ... are the additionals arguments given + to Gamestate.switch.

+ + + + +
Parameters:[gamestate]to:target gamestate.
...:additional arguments to pass
Returns:the result of to:enter(current, ...)
+
+ + +
function Gamestate.update(dt)^ top + Calls update(dt) on current gamestate. +
+ + +
function Gamestate.draw()^ top + Calls draw() on current gamestate. +
+ + +
function Gamestate.keypressed(key, unicode)^ top + Calls keypressed(key, unicode) on current gamestate. +
- function Gamestate.update(dt) - - Calls update(dt) on current gamestate. + +
function Gamestate.keyreleased(key)^ top + Calls keyreleased(key) on current gamestate. +
- function Gamestate.draw() + +
function Gamestate.mousereleased(x,y,btn)^ top + Calls mousereleased(x,y,btn) on the current gamestate. +
- Calls draw() on current gamestate. - - - function Gamestate.keypressed(key, unicode) - - Calls keypressed(key, unicode) on current gamestate. - - - function Gamestate.keyreleased(key) - - Calls keyreleased(key on current gamestate. - - - function Gamestate.mousereleased(x,y,btn) - - Calls `mousereleased(x,y,btn) on the current gamestate. - - - Gamestate.registerEvents() - - Registers all above events so you don't need to call then in your love.* routines. It is an error to call this anywhere else than love.load(), since it overwrites the callbacks. Dont worry though, your callbacks will still be executed. + +
function Gamestate.registerEvents()^ top + Registers all above events so you don't need to call then in your love.* routines. +

It is an error to call this anywhere else than love.load(), since it overwrites the + callbacks. Dont worry though, your callbacks will still be executed.

+
+ +

List of callbacks

+
Each gamestate can have a list of callbacks:^ top + + + + + + + + + + + + + + + +
enter(previous, ...)Gets called upon entering the state. Don't call this yourself, use + Gamestate.switch instead.
leave()Gets called upon leaving the state. The same warning as with enter applies.
update(dt)Manully called by Gamestate.update, or automatically like love.update + when using Gamestate.registerEvents().
draw()Manully called by Gamestate.draw, or automatically like love.draw
keypressed(key, unicode)Manully called by Gamestate.keypressed, or automatically like love.keypressed
keyreleased(key)Manully called by Gamestate.keyreleased, or automatically like love.keyreleased
mousereleased(x,y,btn)Manully called by Gamestate.mousereleased, or automatically like love.mousereleased
+