Adventure.js Docs Downloads
Score: 0 Moves: 0

Class: State

Extends: adventurejs.State

Defined in: adventure/State.js, line 6

State is a special class used for storing general state variables. For example, tangible.is is used to store states such as tangible.is.closed, tangible.is.locked, tangible.is.global, etc. This is done chiefly for organizational purposes. With hundreds of properties per asset, it seemed cleaner to group similar types of properties into clusters and access them through dot notation, rather than leave hundreds of properties floating around the top level of each object. The reason to make it a classed object rather than a generic object (as we do for some collections) is so we can add prototype methods and properties that have access to scope of this (meaning the parent asset) and game (the top level game object).

State containers and their values are passed down the inheritance chain. For example: Tangible inherits from Asset, and asset.is.global is available on tangible.is.global. It's also possible to override inherited nested properties. For example: Exit inherits tangible.is.closed and tangible.is.locked, but overrides them with new definitions in order to account for Exit's relationship to the linked class Aperture.

Private Constructor:

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

Parameters:

  • game_name String
    Name of top level game instance that is scoped to window.
  • name String
    Instance name.
Inherited Overrides
IndexMethodsProperties

Index

Methods:

Properties:

Methods Collapse all  |  Expand all

Properties Collapse all  |  Expand all

Documentation generated by JSDoc 3.6.11 on Mon Nov 20 2023 18:02:45 GMT-0800 (Pacific Standard Time)
Found a problem or error in the docs? Report it to docs@adventurejs.com.