Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0

Class: Atom

Defined in: adventure/Atom.js, line 5

Framework class

Atom is a bedrock class that is used as the prime ancestor for all in-game classes. It defines several important base properties including name, class, id, and the set method. Authors should not need to instantiate or subclass Atom. Start with the Tangible class to create new physical Assets, or the Intangible class to create new abstract Assets.

Private Constructor:

var foo = new adventurejs.Atom(game_name, name)

Parameters:

  • game_name String
    A reference back to the top level game object, by way of window[game_name]. Done this way rather than using an object reference in order to avoid circular references, because they're difficult to parse into JSON, the method that's used for saving/restoring game data.
  • name String
    The name of the object in the game world, ie "brass lantern". The name is also used to create the object's id by means of removing periods and spaces and converting to lowercase.
Inherited Overrides

Methods Collapse all  |  Expand all

getInheritance() → {Array}

Defined in: adventure/Atom.js, line 151

getInheritance is a utility method to get an asset's inheritance chain. Returns a list of class names from high to low.

Returns:

Array
hasClass(prop) → {Boolean}

Defined in: adventure/Atom.js, line 131

Parameters:

  • prop String
    Name of the class to test for.
A method to test whether the Atom is an instance of a given class.

Returns:

Boolean
set(props) → {Object}

Defined in: adventure/Atom.js, line 119

Parameters:

  • props Object
    A generic object containing properties to copy to the Object instance.
Provides a chainable shortcut method for setting a number of properties on the instance.

Returns:

Object Returns the instance the method is called on (useful for chaining calls.)
set(props) → {Object}

Defined in: adventure/ParsedNoun.js, line 167

Parameters:

  • props Object
    A generic object containing properties to copy to the Object instance.
Provides a chainable shortcut method for setting a number of properties on the instance.

Returns:

Object Returns the instance the method is called on (useful for chaining calls.)

Properties  | 

game :Getter

Defined in: adventure/Atom.js, line 110

Returns the top level game object. Use this.game.
Name :String

Defined in: adventure/Atom.js, line 97

Name returns the name of the class instance with the first character uppercased.
class :string

Defined in: adventure/Atom.js, line 59

Class identifier to be provided in the asset definition. All game objects start as generic objects that get passed to createAsset, which uses an object's class field to specify a class constructor.
game_name :string

Defined in: adventure/Atom.js, line 47

game_name stores the name of the current game instance as scoped to window. (By default, we use "MyGame", but you can use any name.) In order to refer to the game object, we use window[this.game_name]. We store a string instead of the object itself in order to avoid problems caused by circular references during JSON encoding, which is used extensively for managing game state and saved games.
id :string

Defined in: adventure/Atom.js, line 83

A unique ID for the game asset, based on the object name provided in the asset definition.
name :string

Defined in: adventure/Atom.js, line 73

Class identifier to be provided in the asset definition. All game objects start as generic objects that get passed to createAsset, which uses an object's class field to specify a class constructor.
UID :string

Defined in: adventure/Atom.js, line 93

A unique numerical ID for the game asset. Currently unused but included as a potential alternative to id.