mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
Document gamestate:init()
This commit is contained in:
parent
d4693a35e8
commit
097fa8b090
15
index.html
15
index.html
@ -133,6 +133,8 @@
|
|||||||
<p>A gamestate can define (nearly) all callbacks that LÖVE defines. In addition, there are callbacks
|
<p>A gamestate can define (nearly) all callbacks that LÖVE defines. In addition, there are callbacks
|
||||||
for entering and leaving a state.:</p>
|
for entering and leaving a state.:</p>
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>init()</dt>
|
||||||
|
<dd>Called once before entering the state. See <a href="#gamestate-switch">switch()</a>.</dd>
|
||||||
<dt>enter(previous, ...)</dt>
|
<dt>enter(previous, ...)</dt>
|
||||||
<dd>Called when entering the state. See <a href="#gamestate-switch">switch()</a>.</dd>
|
<dd>Called when entering the state. See <a href="#gamestate-switch">switch()</a>.</dd>
|
||||||
<dt>leave()</dt>
|
<dt>leave()</dt>
|
||||||
@ -163,13 +165,13 @@
|
|||||||
|
|
||||||
<div class="example">Example:
|
<div class="example">Example:
|
||||||
<pre><code class="lua">menu = Gamestate.new()
|
<pre><code class="lua">menu = Gamestate.new()
|
||||||
function menu:enter(previous, background_image)
|
function menu:init() -- run only once
|
||||||
self.background = background_image
|
self.background = love.graphics.newImage('bg.jpg')
|
||||||
Buttons.initialize()
|
Buttons.initialize()
|
||||||
end
|
end
|
||||||
|
|
||||||
function menu:leave()
|
function menu:enter(previous) -- run every time the state is entered
|
||||||
Buttons.cleanup()
|
Buttons.setActive(Buttons.start)
|
||||||
end
|
end
|
||||||
|
|
||||||
function menu:update(dt)
|
function menu:update(dt)
|
||||||
@ -228,8 +230,9 @@ end</code></pre>
|
|||||||
<div class="definition">function <span class="name">switch</span><span class="arglist">(to, ...)</span><a class="top" href="#gamestate">^ top</a></div>
|
<div class="definition">function <span class="name">switch</span><span class="arglist">(to, ...)</span><a class="top" href="#gamestate">^ top</a></div>
|
||||||
<p>Switch to a gamestate, with any additional arguments passed to the new state.</p>
|
<p>Switch to a gamestate, with any additional arguments passed to the new state.</p>
|
||||||
<p>Switching a gamestate will call the <a href="#gamestate-callbacks"><code>leave()</code></a> callback on
|
<p>Switching a gamestate will call the <a href="#gamestate-callbacks"><code>leave()</code></a> callback on
|
||||||
the current gamestate, replace the current gamestate with <code>to</code> and finally call
|
the current gamestate, replace the current gamestate with <code>to</code>, call the
|
||||||
<a href="#gamestate-callbacks"><code>enter(old_state, ...)</code></a> on the new gamestate.</p>
|
<a href="#gamestate-callbacks"><code>init()</code></a> function if the state was not yet inialized and
|
||||||
|
finally call <a href="#gamestate-callbacks"><code>enter(old_state, ...)</code></a> on the new gamestate.</p>
|
||||||
<div class="arguments">Parameters:
|
<div class="arguments">Parameters:
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Gamestate <code>to</code></dt>
|
<dt>Gamestate <code>to</code></dt>
|
||||||
|
Loading…
Reference in New Issue
Block a user