Adventure.js Docs Downloads
Score: 0 Moves: 0

Class: Display

Defined in: adventure/Display.js, line 9

Display creates and manages the game display, including the main input and output areas and the status bar. It also manages custom compasses, verb docks and inventory docks. Authors can customize the display with custom CSS. CSS styles for Display can be found in adventurejs.css. To learn more, see the

Private Constructor:

var foo = new adventurejs.Display(game, displayElId)

Parameters:

  • game Game
    A reference to the game instance.
  • displayElId displayElId | HTMLElement
    An ID for an HTML element to use as a display.
Inherited Overrides
IndexMethodsProperties

Methods Collapse all  |  Expand all

clearInput()

Defined in: adventure/display/clearInput.js, line 9

Clear the input field
clearOutput()

Defined in: adventure/display/clearOutput.js, line 9

Clear the game display.
createCompass(properties) → {Element}

Defined in: adventure/display/createCompass.js, line 9

Parameters:

  • properties Object
    HTML ID and CSS classes.
createCompass() is a method for creating compasses, including the default compass in the status bar, and any custom compasses. It takes a generic object containing an id and an optional list of css classes to be applied to a compass's HTML element. Compasses will be created at runtime. Compasses can be styled with any custom CSS. Compasses will be updated to show available exits any time the location changes. To create a new compass:
MyGame.createCompass({ 
  "id":"MyCompass",
  "cssclasses":["custom"]
});
For more information, see How to Create a Compass.

Returns:

Element Returns the HTML element of the compass.
createImageDock(properties) → {Element}

Defined in: adventure/display/createImageDock.js, line 9

Parameters:

  • properties Object
    HTML ID, CSS classes, and verbs.
createImageDock() is a method for creating custom image docks. It takes a generic object containing an id, an optional list of css classes to be applied to the element, and an object containing image id / image url pairs. Image docks will be created at runtime, and can be styled with any custom CSS. To create a new image dock:
MyGame.createImageDock({ 
  "id":"MyImageDock",
  "cssclasses":["custom"],
  "images": [
    [ "myimage_01": "/images/myimage_01.jpg" ],
    [ "myimage_02": "/images/myimage_02.jpg" ],
  ],
});
For more information, see How to Create an Image Dock.

Returns:

Element Returns the HTML element of the verb dock.
createInventoryDock(properties) → {Element}

Defined in: adventure/display/createInventoryDock.js, line 9

Parameters:

  • properties Object
    HTML ID, CSS classes, and verbs.
createInventoryDock() is a method for creating custom inventory docks. It takes a generic object containing an id and an optional list of css classes to be applied to the element. Inventory docks will be created at runtime, and can be styled with any custom CSS. To create a new inventory dock:
MyGame.createInventoryDock({ 
  "id":"MyInventoryDock",
  "cssclasses":["custom"]
});
For more information, see How to Create an Inventory Dock.

Returns:

Element Returns the HTML element of the verb dock.
createVerbDock(properties) → {Element}

Defined in: adventure/display/createVerbDock.js, line 9

Parameters:

  • properties Object
    HTML ID, CSS classes, and verbs.
createVerbDock() is a method for creating custom verb docks. It takes a generic object containing an id, a list of verbs, and an optional list of css classes to be applied to the element. Any verbs supplied will have buttons created for them. Verb docks will be created at runtime, and can be styled with any custom CSS. To create a new verb dock:
MyGame.createVerbDock({ 
  "id":"MyVerbDock",
  "cssclasses":["custom"],
  "verbs": ["save","restore","examine","take","use","drop"],
});
For more information, see How to Create a Verb Dock.

Returns:

Element Returns the HTML element of the verb dock.
initialize(props) → {adventurejs.Display}

Defined in: adventure/display/initialize.js, line 8

Parameters:

  • props Object
    A generic object containing properties to copy to the DisplayObject instance.
Initialize the game display. Creates all the necessary HTML elements.

Returns:

adventurejs.Display Returns the instance the method is called on (useful for chaining calls.)
print(msg, classes)

Defined in: adventure/display/print.js, line 9

Todos: add ability to pause at screen height so excess text doesn't scroll off screen

Parameters:

  • msg String
    An arbitrary string.
  • classes String
    Optional class(es) to apply to output.
Global method for printing text to game display.
printInput(input)

Defined in: adventure/display/printInput.js, line 9

Parameters:

  • input String
    An arbitrary string.
Print the player's input back to game display.
printWithInput(msg, classes)

Defined in: adventure/display/printWithInput.js, line 9

Parameters:

  • msg String
    An arbitrary string.
  • classes String
    Optional class(es) to apply to output.
Print a message preceded by player's input back to game display.
sendToInput()

Defined in: adventure/display/sendToInput.js, line 9

Takes a string and writes it to the input field without submitting it to the parser.
set(props) → {adventurejs.Display}

Defined in: adventure/display/set.js, line 8

Parameters:

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

Returns:

adventurejs.Display Returns the instance the method is called on (useful for chaining calls.)
setRoom(name) → {adventurejs.Display}

Defined in: adventure/display/setRoomName.js, line 9

Parameters:

  • name String
    Sets the Status Bar's Room field.
Set Room in status bar.

Returns:

adventurejs.Display Returns the instance the method is called on (useful for chaining calls.)
setRoomImage(id) → {adventurejs.Display}

Defined in: adventure/display/setRoomImage.js, line 9

Parameters:

  • id String
    The id of an image in game.image_lookup.
Set Room image if there is one.

Returns:

adventurejs.Display Returns the instance the method is called on (useful for chaining calls.)
setScore(score) → {Display}

Defined in: adventure/display/setScore.js, line 9

Parameters:

  • score String
    Sets the Status Room field.
Set Score in status bar.

Returns:

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

Defined in: adventure/display/unsetCompasses.js, line 9

Reset exits in status bar and custom compass roses.
unsetImageDocks(properties)

Defined in: adventure/display/unsetImageDocks.js, line 9

Parameters:

  • properties Object
Unset images in image docks.
unsetInventoryDocks(properties)

Defined in: adventure/display/unsetInventoryDocks.js, line 9

Parameters:

  • properties Object
Unset inventory in inventory docks.
unsetVerbDocks(properties)

Defined in: adventure/display/unsetVerbDocks.js, line 9

Parameters:

  • properties Object
Unset verbs in verb docks.
updateCompasses(exits)

Defined in: adventure/display/updateCompasses.js, line 9

Parameters:

  • exits String
Set exits in status bar and custom compass roses.
updateImageDocks(properties)

Defined in: adventure/display/updateImageDocks.js, line 9

Parameters:

  • properties Object
Set images in image docks.
updateInventoryDocks(properties)

Defined in: adventure/display/updateInventoryDocks.js, line 9

Todos: different lists for specific docks

Parameters:

  • properties Object
Set inventory in inventory docks.
updateVerbDocks(properties)

Defined in: adventure/display/updateVerbDocks.js, line 9

Parameters:

  • properties Object
Set verbs in verb docks.

Properties Collapse all  |  Expand all

author :String

Defined in: adventure/Display.js, line 122

Default value: ""

The game's author.
compasses :compasses

Defined in: adventure/Display.js, line 41

Default value: []

An array that contains a list of references to the HTML element of any compasses, including the one in the status bar as well as any custom compasses.
displayEl :HTMLElement

Defined in: adventure/Display.js, line 74

Default value: undefined

A reference to the game's HTML display element.
displayElId :HTMLElement

Defined in: adventure/Display.js, line 81

Default value: undefined

The ID of the game's HTML display element.
game :Object

Defined in: adventure/Display.js, line 29

Default value: {}

A reference back to the main Game object.
imagedocks :imagedocks

Defined in: adventure/Display.js, line 66

Default value: []

An array that contains a list of references to the HTML elements of any image docks.
inventorydocks :inventorydocks

Defined in: adventure/Display.js, line 58

Default value: []

An array that contains a list of references to the HTML elements of any inventory docks.
room :String

Defined in: adventure/Display.js, line 139

Default value: ""

The current room's name.
score :String

Defined in: adventure/Display.js, line 156

Default value: ""

The current score.
title :String

Defined in: adventure/Display.js, line 88

Default value: ""

The game's title.
verbdocks :verbdocks

Defined in: adventure/Display.js, line 50

Default value: []

An array that contains a list of references to the HTML elements of any verb docks.
version :String

Defined in: adventure/Display.js, line 105

Default value: ""

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