Class: PodJS

PodJS

Main environment for pod.js.

The class has a static registry of pod classes which have been loaded. Note that only one version of each Pod class can be registered globally per page. Pod classes get registered by their corresponding scripts, loaded by the html page.

Multiple PodJS environments can be created on the same page via instances of this class. Each instance has its own timer and its own instances of the registered pods, created lazily in dependency order when requested by the application.

The optional options object provided contains both environment settings and settings that are applicable to specific pods. Pods will consume only the options they care about.

Author: markroth8

new PodJS(options)

Constructs a new PodJS environment with the given options.
Parameters:
Name Type Argument Description
options object <optional>
An Object containing options for the environment. Parameters:
Property Type Argument Default Description
fps int <optional> 30 Frames per second the ticks should ideally run.
Source:

Classes

BlockInfo
Pod
PodInitParams
ResourceInfo
ScratchPod
Script
ScriptBuilder
ScriptContext

Members

<static> POD_CLASSES :object

Object providing a map of all pod class names to the corresponding pod class. New pod classes are registered via PodJS.REGISTER_POD_CLASS.
Type:
  • object
Source:

Methods

<static> REGISTER_POD_CLASS(podName, podClass)

Called by Pods to reigster with the environment.

This should never be called by an application. Pods call this method when the browser has loaded their class.

Parameters:
Name Type Description
podName The universally-unique name (across all Pods anyone has ever written) of the pod to register. Use podjs.com to register your name.
podClass The pointer to the constructor function of the class that is used to create a new pod.
Source:

getOptions() → {PodJS.Options}

Source:
Returns:
A clone of the options passed to this environment.
Type
PodJS.Options

pod(name) → {Pod}

Retrieves the instance of the pod with the given name that is bound to this environment. If there is no such pod registered, the PodJS environment will instantiate one. Note this might also cause a cascade of other pods to be instantiated and registered.

Only pod classes that have been registered can be instantiated. This is normally accomplished by adding script tags to the html file.

Parameters:
Name Type Description
name string The name and major version of the pod to retrieve (e.g. "scratch").
Source:
Returns:
The instance of the pod with the given name that is registered with this environment.
Type
Pod

resetAllScripts()

Resets all scripts in all pods back to the first instruction.
Source:

tick()

Called at approximately 30 frames per second to animate all resources.

This calls tick on each registered pod, resource and script.

Source: