Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0

Defined in: adventure/Display.js, line 8

Description

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

Methods Collapse all  |  Expand all

clearInput
clearInput()

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

Clear the input field
clearOutput
clearOutput()

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

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

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

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 GUI Compasses.

Returns:

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

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

Parameters:

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

Returns:

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

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

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
print(msg, classes)

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

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
printInput(input)

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

Parameters:

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

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

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
sendToInput()

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

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

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

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.)
unsetCompasses
unsetCompasses()

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

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

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

Parameters:

  • properties Object
Unset one dock.
unsetDocks
unsetDocks(properties)

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

Parameters:

  • properties Object
Unset docks.
update
update() → {adventurejs.Display}

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

Update all visual elements of the display.

Returns:

adventurejs.Display Returns the instance the method is called on (useful for chaining calls.)
updateCompasses
updateCompasses(exits)

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

Parameters:

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

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

Parameters:

  • properties Object
Update content list in content docks.
updateExitDocks
updateExitDocks(properties)

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

Parameters:

  • properties Object
Update exits in exit docks.
updateInventoryDocks
updateInventoryDocks(properties)

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

Todos: different lists for specific docks

Parameters:

  • properties Object
Set inventory in inventory docks.
updateRoom
updateRoom() → {adventurejs.Display}

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

Concatenate room name + player situation to status bar.

Returns:

adventurejs.Display Returns the instance the method is called on (useful for chaining calls.)
updateRoomDocks
updateRoomDocks(properties)

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

Parameters:

  • properties Object
Update room in room docks.
updateRoomImage
updateRoomImage(id) → {adventurejs.Display}

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

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.)
updateScore
updateScore(score) → {adventurejs.Display}

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

Parameters:

  • score String
    Update the score in the status bar.
Set Score in status bar.

Returns:

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

Properties  | 

author
author :String

Defined in: adventure/Display.js, line 170

Default value: ""

The game's author.
compasses
compasses :compasses

Defined in: adventure/Display.js, line 42

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.
contentdocks
contentdocks :contentdocks

Defined in: adventure/Display.js, line 67

Default value: []

An array that contains a list of references to the HTML elements of any room content docks.
displayEl
displayEl :HTMLElement

Defined in: adventure/Display.js, line 107

Default value: null

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

Defined in: adventure/Display.js, line 114

Default value: null

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

Defined in: adventure/Display.js, line 99

Default value: []

An array that contains a list of references to the HTML elements of all docks.
exitdocks
exitdocks :exitdocks

Defined in: adventure/Display.js, line 75

Default value: []

An array that contains a list of references to the HTML elements of any exit docks.
game
game :Object

Defined in: adventure/Display.js, line 35

Default value: {}

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

Defined in: adventure/Display.js, line 91

Default value: []

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

Defined in: adventure/Display.js, line 83

Default value: []

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

Defined in: adventure/Display.js, line 182

Default value: ""

The current room's name.
roomdocks
roomdocks :roomdocks

Defined in: adventure/Display.js, line 59

Default value: []

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

Defined in: adventure/Display.js, line 194

Default value: ""

The current score.
title
title :String

Defined in: adventure/Display.js, line 146

Default value: ""

The game's title.
verbdocks
verbdocks :verbdocks

Defined in: adventure/Display.js, line 51

Default value: []

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

Defined in: adventure/Display.js, line 158

Default value: ""

The game's version.