API Docs for: v0.1.0
Show:

ObjectFactory Class

Extends Object

The object factory makes it simple to create and add objects to a parent. One is added to a State's world and camera by default, but they can be used for any parent but they can only belong to a single state.

Constructor

ObjectFactory

(
  • state
  • parent
)

Parameters:

  • state State

    The game state this factory belongs to

  • parent Container

    The container to act as the parent for created objects

Item Index

Methods

audio

(
  • key
  • [settings]
)
AudioPlayer

Creates a new AudioPlayer to play the sound passed in

Parameters:

  • key String

    The unique cache key for the preloaded audio

  • [settings] Object optional

    All the settings for the audio player (see AudioManager.add for all settings)

Returns:

AudioPlayer:

The player added

bitmaptext

(
  • text
  • font
  • interactive
)
BitmapText

Creates a new instance of BitmapText

Parameters:

  • text String

    The text for the BitmapText to display

  • font String

    The key for the bitmap font loaded into the cache

  • interactive Boolean

    Can the item be interacted with by mouse (clicked, dragged, etc)

Returns:

BitmapText:

The bitmap text object added

gui

(
  • texture
  • interactive
)
GuiItem

Creates a new gui item and adds it to the Camera's GUI

Parameters:

  • texture String | Texture

    The texture for the item, or the key for one in the cache

  • interactive Boolean

    Can the item be interacted with by mouse (clicked, dragged, etc)

Returns:

GuiItem:

The new gui item added

obj

(
  • object
)
Mixed

Adds a generic object to the world or camera

Parameters:

  • object Mixed

    Any game object you want to add to the parent

Returns:

Mixed:

Returns the added object

sprite

(
  • texture
  • [frame=null]
  • [physics=true]
)
Sprite

Creates a new sprite and adds it to the game world

Parameters:

  • texture String | Texture

    The texture for the sprite, or the key for one in the cache

  • [frame=null] String | Number optional

    A specific frame of a sprite sheet to use, either the index or string key depending on the type of the sheet when loaded.

  • [physics=true] Boolean optional

    Should this sprite be added to the physics simulation?

Returns:

Sprite:

The sprite added

tilemap

(
  • key
  • [constrain=true]
)
Tilemap

Creates a new tilemap to add to the world

Parameters:

  • key String

    The unique cache key for the preloaded tilemap data

  • [constrain=true] Boolean optional

    Should the camera be constrained to this tilemap's size?

Returns:

Tilemap:

The tilemap added