OLPCities/Core: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 22: | Line 22: | ||
Gl_cookie(String) Constructor for a cookie |
Gl_cookie(String) Constructor for a cookie |
||
Gl_hook(String) Hooks a function to a "timer loop". The string passed is the actual |
|||
Gl_hook String Hooks a function to the gamelib timer loop. The string passed is the actual name of the function to be hooked. This function is very useful for tying your functions into the gamelib engine, which will keep things in sync and remove the need for other timers which take valuable CPU cycles |
|||
name of the function to be hooked. |
|||
Gl_layer Numeric, Numeric, Numeric, String Layer constructor, read the layer docs for further details |
|||
Gl_makedegs (none) Called automatically. Fills Gl_sin and Gl_cos arrays at startup |
|||
Gl_preloader(String) Preload images. |
|||
Gl_preloader String[...] Used to preload images. This function can be passed any number of strings specifying image URLs (ie: "images/picture.gif","images/anotherpic.gif"). Fills an array called Gl_preimage. Also updates Gl_totalpreimages with number of images preloaded |
|||
Gl_scrollbars String Turns browser scrollbars on or off for page or frame script is in. String is either "on" or "off". * Note: Only works with Internet Explorer. |
|||
Gl_scrollWindow Numeric, Numeric Scrolls the browser window by x,y where x is first argument and y is second. You cannot scroll past the edges of the document! |
|||
Be aware that Netscape/Mozilla browsers require scrollbars in the window for scrolling to work. This can be overcome with Mozilla/Netscape 6 by creating a frameset with the game's frame having the scrollbars switched off. Then inside this frame, place an iframe, sized bigger than the outer frame, so its scrollbars cannot be seen. Your script will be inside this iframe. You can then scroll the iframe window using this method, and to a player, it will look just like a normal frame being scrolled - a la IE4/5! The advantage of using this scroll method, rather than moving all the sprites is that it uses the computer's hardware scrolling, and so is very fast and smooth! |
|||
Gl_setTimerSpeed Numeric NOTE: This function is deprecated. Please use Gl_calibrate instead. |
|||
Set the timer speed. This will affect the speed the gamelib runs at, based on 1/1000ths of a second between screen updates. Default is 50 (20 frames per second), since it seems the optimum speed for the wide range of speed of PCs/Macs out there. Sure, you can run the gamelib at some insane speed on a dual P3 800mhz by setting this to 1, but you'll annoy people with slower machines unless you have simple (for the CPU) animation |
|||
Gl_start (none) Starts the gamelib timer loop. Sprites will not operate until this has been called |
|||
⚫ | |||
Gl_unhook String Unhooks a function. Pass it a string containing the name of the function to unhook |
|||
Gl_start() Starts the "timer loop". |
|||
⚫ | |||
Gl_unhook(String) Unhooks a function. |
|||
</pre> |
</pre> |
Revision as of 13:02, 21 September 2006
This library is part of the Gamelib, created by Scott Porter and updated by Brent Silby. Gamelib is available under the terms of the GNU Library General Public Licence.
To use this library (this Class) add this line to the <HEAD> section of the web page of the Lot:
<script language="Javascript" src="http://www.dmu.com/olpc/gamelib_core.js"></script>
Better to click this link and "save" the library at the same folder of the web page or put it at another folder at the same server and make a reference:
if you put it at the same folder, the line would be:
<script language="Javascript" src="gamelib_core.js"></script>
You don't need to create an "object" of the Class because there will be only one object of it.
Methods
Gl_cookie(String) Constructor for a cookie Gl_hook(String) Hooks a function to a "timer loop". The string passed is the actual name of the function to be hooked. Gl_preloader(String) Preload images. Gl_start() Starts the "timer loop". Gl_stop() Stops the "timer loop" . All game functions and animation will cease. Gl_unhook(String) Unhooks a function.