Line 25: |
Line 25: |
| Please note that using apiLevel 2.0 with the current Luna will result in an error.<br /> | | Please note that using apiLevel 2.0 with the current Luna will result in an error.<br /> |
| | | |
− | =='''on.create'''== | + | ==on.create== |
| <tt>on.create</tt> is removed in apiLevel 2.0 and replaced with <tt>on.construction</tt>.<br /> | | <tt>on.create</tt> is removed in apiLevel 2.0 and replaced with <tt>on.construction</tt>.<br /> |
| This event handler is guaranteed to run before all others.<br /> | | This event handler is guaranteed to run before all others.<br /> |
| | | |
− | ==Graphical== | + | ==Graphical operations== |
− | operations <nowiki>* Most graphical operations are now anti-aliased. This makes that applications look more pretty </nowiki><br /> <nowiki>* </nowiki><tt>gc:setColorRGB</tt> now supports one number as input (as well as the old style). For example, you can do <tt>gc:setColorRGB(0xFF00CC)</tt> or <tt>gc:setColorRGB(0)</tt><br /> <nowiki>* You can not use coordinates for drawing to the screen above/under (-) 32 000. Normally this shouldn't affect anyone, but because of this Cubefield refuses to run. </nowiki><br /> <br /> <nowiki>* In apiLevel 2.0 </nowiki><tt>platform.gc()</tt> is removed and replaced with <tt>platform.withGC()</tt>. An example of it:<br /> <div class="codeheader">Code: [javascript:void(0) Select All] | [javascript:void(0) Copy To Clipboard]</div><div id="code_a2" class="code"> {| | | <div id="code_tda2"><font face="monospace"><br /> function getStringWidth(gc, str)<br />  return gc:getStringWidth(str)<br /> end<br /> <br /> function on.construction()<br />  local strw = platform.withGC(getStringWidth, "The game")<br /> end<br /> </font></div> |} </div><br /> So what it does it call the function you give as first argument and pass a dummy GC to it. <br /> '''D2Editor''' D2Editor is greatly improved, and it finally useful <br /> <br /> '''require''' There are three modules that you can 'require': physics, color, and strict.<br /> The physics module is the chipmunk physics engine.<br /> color is just a table containing colors. color.red (or color["red"]) will return the color code for red.<br /> I have no idea what strict is or does [[Image:tongue.gif|Tongue]]<br /> <br /> Usage: <tt>require 'modulename'</tt><br /> <br /> '''Physics''' Maybe the best part of it of. OS 3.2 now includes the Open Source Chipmunk physics engine, and you can use it right from Lua!<br /> This will allow some great games and applications <br /> However it's is far to complex to detail in this post, so I will probably write a tutorial about it soon <br /> <br /> '''Image''' Normally 3.2 would have many updates to the image, but sadly enough they did not make 3.2 and are pushed for the next OS.<br /> However, there is one function that made it, and that is <tt>image.rotate</tt>. This allows you to rotate images in anyway.<br /> But beware, it is not the fastest function out there.<br /> '''Math''' <tt>math.eval</tt> has got some friends: <tt>math.evalStr</tt>, <tt>math.getEvalSettings</tt> and <tt>math.setEvalSettings</tt>.<br /> '''Platform''' I already mentioned <tt>platform.withGC</tt>, but there are still two other newcomers:<br /> <nowiki>* </nowiki><tt>platform.registerErrorHandler</tt>, this allows you to take actions when an error occurs in your document. Pretty nice <br /> <nowiki>* </nowiki><tt>platform.window:setFocus</tt>, regain focus in your script.<br /> '''Variable''' <nowiki>* </nowiki><tt>var.recallAt</tt>, fetch data from a certain spot in a list or matrix<br /> <nowiki>* </nowiki><tt>var.makeNumericList</tt>, create a list in the symbol table. The create list will work much more efficient with other var functions.<br /> <br /> <br /> <br /> Well, that's about it. I'm sure there are some stuff I forgot, but you can find them all in the API documentation here -- Link to doc --.<br /> Good luck and may the coding force be with you!</div>
| + | * Most graphical operations are now anti-aliased. This makes that applications look more pretty |
| + | * gc:setColorRGB now supports one number as input (as well as the old style). For example, you can do <tt>gc:setColorRGB(0xFF00CC)</tt> or <tt>gc:setColorRGB(0)</tt> |
| + | * You can not use coordinates for drawing to the screen above/under (-) 32 000. Normally this shouldn't affect anyone, but because of this Cubefield refuses to run. |
| + | * In apiLevel 2.0, <tt>platform.gc()</tt> is removed and replaced with <tt>platform.withGC()</tt>. An example of it:<br /> |
| + | [code]function getStringWidth(gc, str) |
| + | return gc:getStringWidth(str) |
| + | end |
| + | function on.construction() |
| + | local strw = platform.withGC(getStringWidth, "The game") |
| + | end[/code] |
| + | So what it does it call the function you give as first argument and pass a dummy GC to it. |
| + | |
| + | ==D2Editor== |
| + | D2Editor is greatly improved, and it finally useful <br /> |
| + | |
| + | ==Require== |
| + | There are three modules that you can 'require': physics, color, and strict.<br /> |
| + | The physics module is the chipmunk physics engine.<br /> |
| + | color is just a table containing colors. (color.red (or color["red"]) will return the color code for red.)<br /> |
| + | We don't know what strict is or does. <br /> |
| + | Usage: <tt>require 'modulename'</tt><br /> |
| + | |
| + | ==Physics== |
| + | Maybe the best part of it of. OS 3.2 now includes the Open Source Chipmunk physics engine, and you can use it right from Lua!<br /> This will allow some great games and applications <br /> Tutorials aobut it coming soon.<br /> |
| + | |
| + | ==Image== |
| + | <tt>image.rotate</tt>. This allows you to rotate images in anyway.<br /> |
| + | |
| + | ==Math== |
| + | New : <tt>math.evalStr</tt>, <tt>math.getEvalSettings</tt> and <tt>math.setEvalSettings</tt>.<br /> |
| + | |
| + | ==Platform== |
| + | I already mentioned <tt>platform.withGC</tt>, but there are still two other newcomers:<br /> |
| + | * <tt>platform.registerErrorHandler</tt>, this allows you to take actions when an error occurs in your document. |
| + | * <tt>platform.window:setFocus</tt>, regain focus in your script.<br /> |
| + | |
| + | ==Variable== |
| + | * <tt>var.recallAt</tt>, fetch data from a certain spot in a list or matrix<br /> |
| + | * <tt>var.makeNumericList</tt>, create a list in the symbol table. The create list will work much more efficient with other var functions. |