ObjectFactory Class
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
Methods
audio
-
key -
[settings]
Creates a new AudioPlayer to play the sound passed in
Parameters:
-
keyStringThe unique cache key for the preloaded audio
-
[settings]Object optionalAll the settings for the audio player (see AudioManager.add for all settings)
Returns:
The player added
bitmaptext
-
text -
font -
interactive
Creates a new instance of BitmapText
Parameters:
-
textStringThe text for the BitmapText to display
-
fontStringThe key for the bitmap font loaded into the cache
-
interactiveBooleanCan the item be interacted with by mouse (clicked, dragged, etc)
Returns:
The bitmap text object added
gui
-
texture -
interactive
Creates a new gui item and adds it to the Camera's GUI
Parameters:
-
textureString | TextureThe texture for the item, or the key for one in the cache
-
interactiveBooleanCan the item be interacted with by mouse (clicked, dragged, etc)
Returns:
The new gui item added
obj
-
object
Adds a generic object to the world or camera
Parameters:
-
objectMixedAny game object you want to add to the parent
Returns:
Returns the added object
sprite
-
texture -
[frame=null] -
[physics=true]
Creates a new sprite and adds it to the game world
Parameters:
-
textureString | TextureThe texture for the sprite, or the key for one in the cache
-
[frame=null]String | Number optionalA 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 optionalShould this sprite be added to the physics simulation?
Returns:
The sprite added