Instrument
An instrument is a device that displays some data. Instruments have sprites has a base image and animating elements are used to show some state. The instrument acts as a container to all related elements that make up an instrument.
JLS.core.Instrument
new Instrument(options)
// Implementation example
import { Instrument } from 'path/to/core'
const engineN1 = new Instrument({
origin: { ref: 'engine-n1', x: 60, y: 37, w: 268, h: 108 },
baseImagePrefix: 'eicas-unit',
baseImageKey: 'images.spritesheet.engine-n1',
})
options
The word "options" is used somewhat loosely here as most of the fields are required. Actual optional parameters will have an optional flag.
| Name | Type | Default | Description |
|---|---|---|---|
| origin | object | { ref: undefined } | References used to setup and position the instrument. Keys: ref, x, y, w, h. See originRef, originX, originY, originW, and originH |
| baseImagePrefix | string | null | optional The prefix to use when retrieving a global asset from the global asset loader. |
| baseImageKey | string | null | optional The key of the image according to the texture atlas. Sprites are automatically located at images.spritesheet.[key] when loaded with the global asset loader. |
| baseImageId | string | null | optional The key of the image according to the texture atlas. Sprites are automatically located at images.spritesheet.[key] when loaded with the global asset loader. When no prefix is needed, use this. |
| bgImage | string | null | optional The background image to set and use for this instrument. |
| bgColor | string | null | optional The background color to set and use for this instrument. |
| clippingImage | string | null | optional [pending implementation] |
| bootPriority | integer,string | 1 | optional [pending implementation] |
| visibility | integer | 1 | optional The visibility of this instrument. |
Members
originRef
A string reference that can be set to uniquely identify this object.
originX
The X position of this object on a canvas.
originY
The Y position of this object on a canvas.
originW
The width of the object when displayed on a canvas.
originH
The height of the ojbect when displayed on a canvas.
baseImagePrefix
The prefix to use when retrieving a global asset from the global asset loader.
baseImageKey
The key of the image according to the texture atlas. Sprites are automatically located at images.spritesheet.[key] when loaded with the global asset loader.
baseImageId
The key of the image according to the texture atlas. Sprites are automatically located at images.spritesheet.[key] when loaded with the global asset loader. When the prefix doesn't need to be changed, use this.
bgImage
The background image to set and use for this instrument.
bgColor
The background color to set and use for this instrument.
clippingImage
// TODO: determine if clipping images are needed. this is not implemented and may no longer be required.
bootPriority
[pending implementation]
// TODO: implement boot loader script and assign instruments a boot priority, which can be random
visibility
The visibility of this instrument.
elements
A directory of local elements for this particular instrument.
sprites
A directory of local sprites for this particular instrument.
Methods
debugModeOn
Shows the colored debug regions.
debugModeOff
Hides the colored debug regions.
addAnimatedElement(element)
Adds an animating element to the instrument. This does not immediately make the element show or added to the stage. Only a reference to signify that the element belongs to this instrument is made. The element is positioned and shown later in the setup method.
| Name | Type | Default | Description |
|---|---|---|---|
| element | JLS.elements.{any} | --- | the element to add and use on this instrument. |
load
Initializes the instrument. Called automagically by the parent device display. Only caveat is that .load must be called on parent device when assets are finished loading.