123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html>
- <head>
- <title>Module anim</title>
- <link rel="stylesheet" href="../luadoc.css" type="text/css" />
- <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
- </head>
- <body>
- <div id="container">
- <div id="product">
- <div id="product_logo"></div>
- <div id="product_name"><big><b></b></big></div>
- <div id="product_description"></div>
- </div> <!-- id="product" -->
- <div id="main">
- <div id="navigation">
- <h1>Goo</h1>
- <ul>
-
- <li><a href="../index.html">Index</a></li>
-
- </ul>
- <!-- Module list -->
- <h1>Modules</h1>
- <ul>
- <li><strong>anim</strong></li>
-
- <li>
- <a href="../modules/goo.html">goo</a>
- </li>
- <li>
- <a href="../modules/goo.button.html">goo.button</a>
- </li>
- <li>
- <a href="../modules/goo.checkbox.html">goo.checkbox</a>
- </li>
- <li>
- <a href="../modules/goo.colorpick.html">goo.colorpick</a>
- </li>
- <li>
- <a href="../modules/goo.image.html">goo.image</a>
- </li>
- <li>
- <a href="../modules/goo.null.html">goo.null</a>
- </li>
- <li>
- <a href="../modules/goo.object.html">goo.object</a>
- </li>
- <li>
- <a href="../modules/goo.panel.html">goo.panel</a>
- </li>
- <li>
- <a href="../modules/goo.progressbar.html">goo.progressbar</a>
- </li>
- <li>
- <a href="../modules/goo.text.html">goo.text</a>
- </li>
- <li>
- <a href="../modules/goo.textinput.html">goo.textinput</a>
- </li>
- </ul>
- <!-- File list -->
- </div><!-- id="navigation" -->
- <div id="content">
- <h1>Module <code>anim</code></h1>
- <p>Animation library. <br/>This library gives you functions to animate a variable from one value to another. <br/>You can group and chain multiple animations, for instance grouping two animations that <br/>animate the x and y positions of an object. <br/>How anim interpolates between the two values are set by animation styles such as linear, quadIn etc. <br/>To load do the following. <pre class="example"> anim = require 'anim/anim'<br/> function love.update(dt)<br/> anim:update(dt)<br/> end </pre></p>
- <p><small><b>Release:</b> 2010-02-26 Version 1</small></p>
- <h2>Functions</h2>
- <table class="function_list">
- <tr>
- <td class="name" nowrap><a href="#anim.chain:new">anim.chain:new</a> (...)</td>
- <td class="summary">Creates an animation chain that plays multiple animations one after another.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim.chain:onFinish">anim.chain:onFinish</a> (...)</td>
- <td class="summary">Callback function when the last animation in the chain finishes </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim.chain:pause">anim.chain:pause</a> ()</td>
- <td class="summary">Pauses the animation chain </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim.chain:play">anim.chain:play</a> ()</td>
- <td class="summary">Plays/resumes the animation chain.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim.group:new">anim.group:new</a> (...)</td>
- <td class="summary">Creates an animation group which can hold individual animations.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim.group:onFinish">anim.group:onFinish</a> ()</td>
- <td class="summary">Callback function when all the animations in the group have finished </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim.group:pause">anim.group:pause</a> ()</td>
- <td class="summary">Pauses all the animations in the group </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim.group:play">anim.group:play</a> ()</td>
- <td class="summary">Plays/resumes all the animations in the group together </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim.group:reverse">anim.group:reverse</a> ()</td>
- <td class="summary">Reverses all the animations in the group </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim.group:setTime">anim.group:setTime</a> (time)</td>
- <td class="summary">Sets the time period of every animation in the group </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:easy">anim:easy</a> (table, key, start, finish, time, style)</td>
- <td class="summary">Convenience function for anim:new().</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:finish">anim:finish</a> ()</td>
- <td class="summary">Finish the animation.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:moveTo">anim:moveTo</a> (object, x, y, time, style, delay)</td>
- <td class="summary">Animates an object from it's current position to another.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:new">anim:new</a> (anim_table)</td>
- <td class="summary">Create a new animation instance.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:onFinish">anim:onFinish</a> ()</td>
- <td class="summary">Callback function when the animation is finished.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:onPause">anim:onPause</a> ()</td>
- <td class="summary">Callback function when anim:pause() is called </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:onPlay">anim:onPlay</a> ()</td>
- <td class="summary">Callback function when anim:play() is called </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:pause">anim:pause</a> ()</td>
- <td class="summary">Pause the animation.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:play">anim:play</a> ()</td>
- <td class="summary">Plays or resumes the animation </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:reverse">anim:reverse</a> ()</td>
- <td class="summary">Reverse the animation.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#anim:update">anim:update</a> (dt)</td>
- <td class="summary">Updates all animations, use inside love.update().</td>
- </tr>
- </table>
- <h2>Tables</h2>
- <table class="table_list">
- <tr>
- <td class="name" nowrap><a href="#anim_table">anim_table</a></td>
- <td class="summary">An animation table </td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#styles">styles</a></td>
- <td class="summary">List of animation styles you can use.</td>
- </tr>
- </table>
- <h2>Examples</h2>
- <table class="table_list">
- <tr>
- <td class="name" nowrap><a href="#Sliding text">Sliding text</a></td>
- <td class="summary">Animate text to slide in from offscreen.</td>
- </tr>
- </table>
- <br/>
- <br/>
- <h2><a name="functions"></a>Functions</h2>
- <dl class="function">
- <dt><a name="anim.chain:new"></a><span>anim.chain:</span><strong>new</strong> ( ... )</dt>
- <dd>
- <p class="func_description">Creates an animation chain that plays multiple animations one after another.</p>
- <h3>Parameters</h3>
- <ul>
-
-
- <li>
- <b>...</b> <i><small></small></i><br/>a list of animations to chain, in order.
- </li>
-
-
- </ul>
- <h3>Return value:</h3>
- <p class="func_return">table: an animation chain.</p>
- </dd>
- <dt><a name="anim.chain:onFinish"></a><span>anim.chain:</span><strong>onFinish</strong> ( ... )</dt>
- <dd>
- <p class="func_description">Callback function when the last animation in the chain finishes</p>
- </dd>
- <dt><a name="anim.chain:pause"></a><span>anim.chain:</span><strong>pause</strong> ( )</dt>
- <dd>
- <p class="func_description">Pauses the animation chain</p>
- </dd>
- <dt><a name="anim.chain:play"></a><span>anim.chain:</span><strong>play</strong> ( )</dt>
- <dd>
- <p class="func_description">Plays/resumes the animation chain.</p>
- </dd>
- <dt><a name="anim.group:new"></a><span>anim.group:</span><strong>new</strong> ( ... )</dt>
- <dd>
- <p class="func_description">Creates an animation group which can hold individual animations.</p>
- <h3>Parameters</h3>
- <ul>
-
-
- <li>
- <b>...</b> <i><small></small></i><br/>multiple animations to group.
- </li>
-
-
- </ul>
- <h3>Return value:</h3>
- <p class="func_return">table: an animation group.</p>
- </dd>
- <dt><a name="anim.group:onFinish"></a><span>anim.group:</span><strong>onFinish</strong> ( )</dt>
- <dd>
- <p class="func_description">Callback function when all the animations in the group have finished</p>
- </dd>
- <dt><a name="anim.group:pause"></a><span>anim.group:</span><strong>pause</strong> ( )</dt>
- <dd>
- <p class="func_description">Pauses all the animations in the group</p>
- </dd>
- <dt><a name="anim.group:play"></a><span>anim.group:</span><strong>play</strong> ( )</dt>
- <dd>
- <p class="func_description">Plays/resumes all the animations in the group together</p>
- </dd>
- <dt><a name="anim.group:reverse"></a><span>anim.group:</span><strong>reverse</strong> ( )</dt>
- <dd>
- <p class="func_description">Reverses all the animations in the group</p>
- </dd>
- <dt><a name="anim.group:setTime"></a><span>anim.group:</span><strong>setTime</strong> ( time )</dt>
- <dd>
- <p class="func_description">Sets the time period of every animation in the group</p>
- <h3>Parameters</h3>
- <ul>
-
-
- <li>
- <b>time</b> <i><small>:number</small></i><br/>time in seconds.
- </li>
-
-
- </ul>
- </dd>
- <dt><a name="anim:easy"></a><span>anim:</span><strong>easy</strong> ( table, key, start, finish, time, style )</dt>
- <dd>
- <p class="func_description">Convenience function for anim:new(). Creates an animation instance. <br/>The animation will automatically play.</p>
- <h3>Parameters</h3>
- <ul>
-
-
- <li>
- <b>table</b> <i><small>:table</small></i><br/>The table holding the value you wish to animate.
- </li>
-
-
-
- <li>
- <b>key</b> <i><small>:string</small></i><br/>The key's value you wish to animate.
- </li>
-
-
-
- <li>
- <b>start</b> <i><small>:number</small></i><br/>The starting value.
- </li>
-
-
-
- <li>
- <b>finish</b> <i><small>:number</small></i><br/>The finishing value.
- </li>
-
-
-
- <li>
- <b>time</b> <i><small>:number</small></i><br/>The time it takes for the animation to complete. (In seconds)
- </li>
-
-
-
- <li>
- <b>style</b> <i><small>:string</small></i><br/>The style of the animation.
- </li>
-
-
- </ul>
- <h3>Return value:</h3>
- <p class="func_return">table: An animation instance.</p>
- <h3>See also:</h3>
- <ul>
-
- <li><a href="../modules/anim.html#styles">
- styles
- </a>
-
- <li><a href="../modules/anim.html#anim_table">
- anim_table
- </a>
-
- <li><a href="">
- anim:new
- </a>
-
- </ul>
- </dd>
- <dt><a name="anim:finish"></a><span>anim:</span><strong>finish</strong> ( )</dt>
- <dd>
- <p class="func_description">Finish the animation. (Instantaneus)</p>
- </dd>
- <dt><a name="anim:moveTo"></a><span>anim:</span><strong>moveTo</strong> ( object, x, y, time, style, delay )</dt>
- <dd>
- <p class="func_description">Animates an object from it's current position to another. <br/>The object must have x and y keys! <br/>The animation will automatically play.</p>
- <h3>Parameters</h3>
- <ul>
-
-
- <li>
- <b>object</b> <i><small>:table</small></i><br/>An object with 'x' and 'y' keys.
- </li>
-
-
-
- <li>
- <b>x</b> <i><small>:number</small></i><br/>The target x position.
- </li>
-
-
-
- <li>
- <b>y</b> <i><small>:number</small></i><br/>The target y position.
- </li>
-
-
-
- <li>
- <b>time</b> <i><small>:number</small></i><br/>The time it takes for the animation to complete. (In seconds)
- </li>
-
-
-
- <li>
- <b>style</b> <i><small>:string</small></i><br/>The style of the animation.
- </li>
-
-
-
- <li>
- <b>delay</b> <i><small>:number</small></i><br/>The time it waits before starting the animation. (In seconds)
- </li>
-
-
- </ul>
- <h3>Return value:</h3>
- <p class="func_return">table: An animation instance.</p>
- <h3>See also:</h3>
- <ul>
-
- <li><a href="../modules/anim.html#anim_table">
- anim_table
- </a>
-
- <li><a href="../modules/anim.html#styles">
- styles
- </a>
-
- </ul>
- </dd>
- <dt><a name="anim:new"></a><span>anim:</span><strong>new</strong> ( anim_table )</dt>
- <dd>
- <p class="func_description">Create a new animation instance.</p>
- <h3>Parameters</h3>
- <ul>
-
-
- <li>
- <b>anim_table</b> <i><small></small></i><br/>A table of animation paremeters.
- </li>
-
-
- </ul>
- <h3>Usage:</h3>
- <pre class="example"> new_animation = anim:new{<br /> table = myTable,<br /> key = 'x_position',<br /> start = 12,<br /> finish = 120,<br /> time = 4,<br /> style = 'linear'<br /> }<br /> </pre><br />
- <h3>Return value:</h3>
- <p class="func_return">table: An animation instance you can call anim methods on.</p>
- <h3>See also:</h3>
- <ul>
-
- <li><a href="../modules/anim.html#anim_table">
- anim_table
- </a>
-
- <li><a href="../modules/anim.html#Sliding text">
- Sliding text
- </a>
-
- </ul>
- </dd>
- <dt><a name="anim:onFinish"></a><span>anim:</span><strong>onFinish</strong> ( )</dt>
- <dd>
- <p class="func_description">Callback function when the animation is finished.</p>
- <h3>Usage:</h3>
- <pre class="example"> new_anim = anim:new( anim_table )<br /> function new_anim:onFinish()<br /> print('animation finished')<br /> end<br /> </pre><br />
- </dd>
- <dt><a name="anim:onPause"></a><span>anim:</span><strong>onPause</strong> ( )</dt>
- <dd>
- <p class="func_description">Callback function when anim:pause() is called</p>
- <h3>See also:</h3>
- <ul>
-
- <li><a href="">
- anim:onFinish
- </a>
-
- </ul>
- </dd>
- <dt><a name="anim:onPlay"></a><span>anim:</span><strong>onPlay</strong> ( )</dt>
- <dd>
- <p class="func_description">Callback function when anim:play() is called</p>
- <h3>See also:</h3>
- <ul>
-
- <li><a href="">
- anim:onFinish
- </a>
-
- </ul>
- </dd>
- <dt><a name="anim:pause"></a><span>anim:</span><strong>pause</strong> ( )</dt>
- <dd>
- <p class="func_description">Pause the animation.</p>
- </dd>
- <dt><a name="anim:play"></a><span>anim:</span><strong>play</strong> ( )</dt>
- <dd>
- <p class="func_description">Plays or resumes the animation</p>
- </dd>
- <dt><a name="anim:reverse"></a><span>anim:</span><strong>reverse</strong> ( )</dt>
- <dd>
- <p class="func_description">Reverse the animation.</p>
- </dd>
- <dt><a name="anim:update"></a><span>anim:</span><strong>update</strong> ( dt )</dt>
- <dd>
- <p class="func_description">Updates all animations, use inside love.update().</p>
- <h3>Parameters</h3>
- <ul>
-
-
- <li>
- <b>dt</b> <i><small>:number</small></i><br/>delta time
- </li>
-
-
- </ul>
- </dd>
- </dl>
- <h2><a name="tables"></a>Tables</h2>
- <dl class="table">
- <dt><a name="anim_table"></a><strong>anim_table</strong></dt>
- <dd>An animation table
- <em>Fields</em>
- <ul>
-
- <li>
- <b>table</b> The table to pass to the anim object
- </li>
-
- <li>
- <b>key</b> The key to animate. (table[key] will be animated).
- </li>
-
- <li>
- <b>start</b> The value the animation starts at. (if nil current table[key] value will be used).
- </li>
-
- <li>
- <b>finish</b> The value the animation finishes at. (if nil current table[key] value will be used).
- </li>
-
- <li>
- <b>time</b> The time it takes for the animation to complete. (in seconds, default 1).
- </li>
-
- <li>
- <b>delay</b> The time it takes for the animation to start after calling anim:play(). (in seconds, default 0).
- </li>
-
- <li>
- <b>style</b> The style of the animation. (a string, default 'linear'). <a href='#styles'>See style</a>.
- </li>
-
- <li>
- <b>styleargs</b> Some styles such as 'elastic' can take extra parameters in the form of a table {arg1,arg2}.
- </li>
-
- </ul>
- </dd>
- <dt><a name="styles"></a><strong>styles</strong></dt>
- <dd>List of animation styles you can use.
- <em>Fields</em>
- <ul>
-
- <li>
- <b>linear</b>
- </li>
-
- <li>
- <b>quartIn</b>
- </li>
-
- <li>
- <b>quartOut</b>
- </li>
-
- <li>
- <b>quartInOut</b>
- </li>
-
- <li>
- <b>quadIn</b>
- </li>
-
- <li>
- <b>quadOut</b>
- </li>
-
- <li>
- <b>quadInOut</b>
- </li>
-
- <li>
- <b>expoIn</b>
- </li>
-
- <li>
- <b>expoOut</b>
- </li>
-
- <li>
- <b>expoInOut</b>
- </li>
-
- <li>
- <b>elastic</b>
- </li>
-
- </ul>
- </dd>
- </dl>
- <h2><a name="examples"></a>Examples</h2>
- <dl class="example">
- <dt><a name="Sliding text"></a><strong>Sliding text</strong></dt>
- <dd>
- <div class="example">
- Here's how: <pre class="example"><br /> anim = require 'anim/anim'<br /> <br /> function love.load()<br /> text = { x = -100, str = 'Woo!' }<br /> new_anim = anim:new{<br /> table = text,<br /> key = 'x',<br /> start = -100<br /> finish = 100,<br /> time = 2,<br /> style = 'quadInOut'<br /> }<br /> new_anim:play()<br /> end<br /> <br /> function love.update(dt)<br /> anim:update(dt)<br /> end<br /> <br /> function love.draw()<br /> love.graphics.print(text.str, text.x, 100)<br /> end<br /> </pre><br />
- </div>
- </dd>
- </dl>
- </div> <!-- id="content" -->
- </div> <!-- id="main" -->
- <div id="about">
- <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
- </div> <!-- id="about" -->
- </div> <!-- id="container" -->
- </body>
- </html>
|