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

Class:Display

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 widgets and inventory widgets. 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, containerId)

Parameters:

  • game Game
    A reference to the game instance.
  • containerId containerId | HTMLElement
    An ID for an HTML element to build the game to.
Inherited Overrides

Methods Collapse all  |  Expand all

appendClassesToLastInput
appendClassesToLastInput(classes)

Defined in: Adventure/Display.js, line 221

Parameters:

  • classes String
Append classes to the last line of input.
appendClassesToLastOutput
appendClassesToLastOutput(classes)

Defined in: Adventure/Display.js, line 233

Parameters:

  • classes String
Append classes to the last line of output.
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 Compass Widgets.

Returns:

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

Defined in: Adventure/Display/createMessageWidget.js, line 8

Parameters:

  • properties Object
    HTML ID and CSS classes.
createMessageWidget() is a method for creating message widgets.

Returns:

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

Defined in: Adventure/Display/createVerbList.js, line 8

Parameters:

  • properties Object
    HTML ID and CSS classes.
createVerbList() is a method for creating verb list widgets.

Returns:

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

Defined in: Adventure/Display/createWidget.js, line 8

Parameters:

  • properties Object
    HTML ID, CSS classes, and verbs.
createWidget() is a method for creating custom widgets. It takes a generic object containing an id, and an optional list of css classes to be applied to the element. Widgets will be created at runtime, and can be styled with any custom CSS. To create a new widget:
MyGame.createWidget({
  "id":"MyRoomWidget",
  "cssclasses":["custom"],
});

Returns:

Element Returns the HTML element of the verb widget.
hideStatusbar
hideStatusbar() → {boolean}

Defined in: Adventure/Display.js, line 247

Hide the game's statusbar.

Returns:

boolean
hideTitlebar
hideTitlebar() → {boolean}

Defined in: Adventure/Display.js, line 273

Hide the game's titlebar.

Returns:

boolean
initialize
initialize(props) → {Object}

Defined in: Adventure/Display/initialize.js, line 7

Parameters:

  • props String | Object
    A container element into which to build the display.
Initialize the game display. Creates all the necessary HTML elements.

Returns:

Object 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. We have to rebuild it due to the way that parseInput broke down the original input to find sentence boundaries.
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.)
showStatusbar
showStatusbar() → {boolean}

Defined in: Adventure/Display.js, line 260

Show the game's statusbar.

Returns:

boolean
showTitlebar
showTitlebar() → {boolean}

Defined in: Adventure/Display.js, line 286

Show the game's titlebar.

Returns:

boolean
unsetCompasses
unsetCompasses()

Defined in: Adventure/Display/unsetCompasses.js, line 8

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

Defined in: Adventure/Display/unsetWidget.js, line 8

Parameters:

  • properties Object
Unset one widget.
unsetWidgets
unsetWidgets(properties)

Defined in: Adventure/Display/unsetWidgets.js, line 8

Parameters:

  • properties Object
Unset widgets.
update
update() → {Object}

Defined in: Adventure/Display/update.js, line 8

Update all visual elements of the display.

Returns:

Object 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.
updateInventoryListWidgets
updateInventoryListWidgets(inventory)

Defined in: Adventure/Display/updateInventoryListWidgets.js, line 8

Todos: different lists for specific widgets

Parameters:

  • inventory Object
Set inventory in inventory widgets.
updateObjectDescriptionWidgets
updateObjectDescriptionWidgets(output, asset)

Defined in: Adventure/Display/updateObjectDescriptionWidgets.js, line 8

Todos: handle images

Parameters:

  • output String
  • asset Object
Update object description in object description widgets.
updateObjectListWidgets
updateObjectListWidgets(properties)

Defined in: Adventure/Display/updateObjectListWidgets.js, line 8

Parameters:

  • properties Object
Update objects list in object widgets.
updateRoom
updateRoom() → {Object}

Defined in: Adventure/Display/updateRoom.js, line 8

Concatenate room name + player situation to status bar.

Returns:

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

Defined in: Adventure/Display/updateRoomDescriptionWidgets.js, line 8

Parameters:

  • properties Object
Update room description widgets.
updateRoomExitsWidgets
updateRoomExitsWidgets(properties)

Defined in: Adventure/Display/updateRoomExitsWidgets.js, line 8

Parameters:

  • properties Object
Update exits in exit widgets.
updateRoomImageWidgets
updateRoomImageWidgets(image) → {Object}

Defined in: Adventure/Display/updateRoomImageWidgets.js, line 8

Parameters:

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

Returns:

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

Defined in: Adventure/Display/updateScore.js, line 8

Parameters:

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

Returns:

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

Properties  | 

author
author :String

Defined in: Adventure/Display.js, line 323

Default value: ""

The game's author.
compass_widgets
compass_widgets :compass_widgets

Defined in: Adventure/Display.js, line 51

Default value: []

An array that contains a list of references to the HTML elements of any compass widgets. Distinct from compasses.
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.
containerId
containerId :HTMLElement

Defined in: Adventure/Display.js, line 138

Default value: null

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

Defined in: Adventure/Display.js, line 131

Default value: null

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

Defined in: Adventure/Display.js, line 35

Default value: {}

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

Defined in: Adventure/Display.js, line 99

Default value: []

An array that contains a list of references to the HTML elements of any inventory widgets.
message_widgets
message_widgets :message_widgets

Defined in: Adventure/Display.js, line 67

Default value: []

An array that contains a list of references to the HTML elements of any message widgets.
object_description_widgets
object_description_widgets :object_description_widgets

Defined in: Adventure/Display.js, line 107

Default value: []

An array that contains a list of references to the HTML elements of any description widgets.
object_list_widgets
object_list_widgets :object_list_widgets

Defined in: Adventure/Display.js, line 83

Default value: []

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

Defined in: Adventure/Display.js, line 335

Default value: ""

The current room's name.
room_description_widgets
room_description_widgets :room_description_widgets

Defined in: Adventure/Display.js, line 75

Default value: []

An array that contains a list of references to the HTML elements of any room widgets.
room_exits_widgets
room_exits_widgets :room_exits_widgets

Defined in: Adventure/Display.js, line 91

Default value: []

An array that contains a list of references to the HTML elements of any exit widgets.
room_image_widgets
room_image_widgets :room_image_widgets

Defined in: Adventure/Display.js, line 115

Default value: []

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

Defined in: Adventure/Display.js, line 347

Default value: ""

The current score.
title
title :String

Defined in: Adventure/Display.js, line 299

Default value: ""

The game's title.
verb_list_widgets
verb_list_widgets :verb_list_widgets

Defined in: Adventure/Display.js, line 59

Default value: []

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

Defined in: Adventure/Display.js, line 311

Default value: ""

The game's version.
widgets
widgets :widgets

Defined in: Adventure/Display.js, line 123

Default value: []

An array that contains a list of references to the HTML elements of all widgets.