Difference between revisions of "API:Functions"

From Spherical
Jump to: navigation, search
(Sphere Runtime: Add more modules to list)
m (Sphere Runtime)
Line 84: Line 84:
 
== Sphere Runtime ==
 
== Sphere Runtime ==
  
The '''Sphere Runtime''' is a standard collection of JavaScript modules included with the engine.  Some modules can even be used in Cellscripts as well!  Unlike the Core API above which was organized by category, the following list is organized by module.  Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 <tt>import</tt> statement and specify the <tt>sphere-runtime</tt> module, like so:
+
The '''Sphere Runtime''' is a standard collection of JavaScript modules included with the engine.  Some modules can even be used in Cellscripts as well!  Unlike the Core API above which was organized by category, the following list is organized by module.  Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 <tt>import</tt> statement and import objects from the <tt>sphere-runtime</tt> or <tt>cell-runtime</tt> module, as appropriate:
  
  import { from, Music, Thread } from 'sphere-runtime'; // in a Sphere game
+
==== In a Sphere game ====
  import { transpile } from 'cell-runtime';             // in a Cellscript
+
 
 +
  import { from, Music, Thread } from 'sphere-runtime';
 +
 
 +
==== In a Cellscript ====
 +
 
 +
  import { assert, transpile } from 'cell-runtime';
  
 
=== <tt>from</tt> Module ===
 
=== <tt>from</tt> Module ===

Revision as of 02:59, 18 August 2017


The Sphere API is the collective name for the set of bindings (functions, objects, and methods) available for use by all Sphere games. The API provides access to a host of convenient features, allowing you to get up and running quickly.


Making new function/object pages

Simple steps:
  1. Before getting started, please check the Article standards and practices.
  2. Click a red link.
  3. Place the following code in the empty edit box:
    1. For a new function: {{subst:functemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}
    2. For a new object: {{subst:objecttemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}
  4. Check the minor edit flag and save.
  5. Click 'edit' at the top of the page to add content.
  6. Try to be objective when writing, and save when you're done.
  7. Remove description from this page, add page link to list at the top of the matching section.


Core API

The Core API provides low-level access to the engine's features and includes all bindings provided directly by the engine. These bindings are exposed to the global scope and can be used without importing any extra modules.

Sphere Game Platform

Debugging

Files and Directories

Random Number Generation

Sphere Runtime

The Sphere Runtime is a standard collection of JavaScript modules included with the engine. Some modules can even be used in Cellscripts as well! Unlike the Core API above which was organized by category, the following list is organized by module. Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 import statement and import objects from the sphere-runtime or cell-runtime module, as appropriate:

In a Sphere game

import { from, Music, Thread } from 'sphere-runtime';

In a Cellscript

import { assert, transpile } from 'cell-runtime';

from Module

image Module

logger Module

music Module

prim Module

random Module

thread Module

...and more to come!