Legacy:Functions

From Spherical
Revision as of 05:57, 4 June 2013 by Apollolux (talk | contribs) (Clipping: clipping rectangle object -> ClippingRectangle)
Jump to: navigation, search

This is a definitive reference of the Sphere API: in other words, the functions that Sphere uses in its JavaScript engine. The page currently mimics the layout of docs/development/api.txt, but is undergoing reorganisation.

Alternatively, the whole Sphere API, sorted by category, with brief descriptions of the functions is available in the API text file mirror itself.

For assistance with using JavaScript itself, consult these links:


Making new function/object pages

Simple steps:
  1. Click a red link.
  2. Place the following code in the empty edit box: {{subst:functemp}} for a new function, or {{subst:objecttemp}} for a new object.
  3. Check the minor edit flag and save.
  4. Click 'edit' at the top of the page to add content.
  5. Try to be objective when writing, and save when you're done.
  6. Remove description from this page, add page link to list at the top of the matching section.



Engine functions

Game control

Accessing installed games

  • Sphere Game object: Holds info about an installed Sphere game.
  • GetGameList(): Get a list of installed Sphere games.
  • ExecuteGame(directory): Execute Sphere game installed in directory.

Script functions

File inclusion

Time

  • GetTime(): Get the number of milliseconds since an arbitrary point in time.

Conversion

System interfaces

Video

Screen size

Clipping

Graphics primitives

API:Functions/Primitives

API:Functions/Input

API:Functions/Networking

Map Engine

API:Functions/Map

Sphere objects

Besides the above, Sphere has a set of built-in objects for more generalized use within projects. Most are loaded from external resource files, but a few (Color, ColorMatrix) are defined solely in script and remain only in-memory during the running of the project.

API:Functions/Sounds

API:Functions/Colors

API:Functions/ColorMatrices

API:Functions/Spritesets

API:Functions/Fonts

API:Functions/WindowStyles

API:Functions/Images

API:Functions/Surfaces

API:Functions/Animations

API:Functions/Filesystem

API:Functions/Files

API:Functions/Log


ByteArray object

  • Sphere ByteArray object: Holds an array of bytes.
  • CreateByteArray(length): Create a new ByteArray.
  • ByteArray.concat(byte_array_object, byte_array_to_append): Returns bytearray with byte_array_to_append attached to the end of it
  • ByteArray.slice(start_slice [, end_slice]): Returns a slice of the bytearray starting at start, and ending at end or the end of the bytearray if end is omitted. If end is a negative number, the end point is started from the end of the bytearray.

Conversion

Data hashing

  • HashByteArray(byte_array): Calculate MD5 'fingerprint' of data in byte_array.