Jet Link Simulations

Jet Link Simulations

  • Docs
  • API Reference
  • Help

Device

The device is a container used to group together all a device's displays and actuators.

JLS.core.Device

new Device(options)

  // Implementation example
  import { Device } from 'path/to/core'

  const EICAS_UNIT  = new Device({
    origin: { ref: 'eicas-unit', x: 0, y: 0, w: 675, h: 900 },
    screenRegion: { x: 30, y: 30, w: 645, h: 860 },
    resources: {
      images: {
        background: 'path/to/background',
        spritesheet: 'path/to/texture/atlas',
      },
    },
    . . .
  })

options

The word "options" is used somewhat loosely here as most of the fields are required. Actual optional parameters will have an optional flag.

NameTypeDefaultDescription
originobject{ ref: undefined, x: undefined, y: undefined, w: undefined, h: undefined }References used to setup and position the device relative to its parent. Keys: ref, x, y, w, h. See originRef, originX, originY, originW, and originH.
screenRegionobject{ x: undefined, y: undefined, w: undefined, h: undefined }The screen's position relative to the device. See screenRegionX, screenRegionY screenRegionW, screenRegionH
backgroundColorstringnulloptional The background color of the device.
debugModebooleanfalseoptional Tells whether or not the device should run in debug mode.
deviceStatestringnormaloptional An arbitrary value that holds a global device "state." Options: normal, error, inopt, paused
currentDisplayinteger0optional index-based reference to the current screen being shown on the device display.
spritesobject{}optional A directory of all the sprites that are local to the device. Any assets passed on construction will be overwritten if assets are also loaded for this device with the JLS.AssetLoader.
displaysobject{}optional A directory of all the displays that make up the device.
actuatorsobject{}optional A directory of all the actuators that make up the device.
resourcesobject{ images: {}, sounds: {} }A directory of all the resources that should be used to initialize the device on the setup method. Items here are loaded by the JLS.AssetLoader and the name is the flatten reference to the data property. For example: resources.images.background is given a key name of [device originRef].images.background

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.

screenRegionX

The X position of the device's screen area relative to the parent container.

screenRegionY

The Y position of the device's screen area relative to the parent container.

screenRegionW

The width of the device's screen area.

screenRegionH

The height of the device's screen area.

hasScreen

A convenience member to check whether or not a device has a screen.

hasActuators

A convenience member to check whether or not a device has actuators.

backgroundColor

The background color of the device.

debugMode

Tells whether or not the device should run in debug mode.

deviceState

An arbitrary value that holds a global device "state." Options: normal, error, inopt, paused

isActiveDevice

A convenience member to check whether or not a device is the current device that being interacted with.

currentDisplay

A convenience member to check what display of the device is the current display. (index-based)

sprites

A directory of all the sprites that are local to the device.

displays

A directory of all the displays that make up the device.

actuators

A directory of all the actuators that make up the device.

resources

A directory of all the resources that should be used to initialize the device on the setup method.

bootLoader

[pending implementation] A set of instructions the device should follow to animate elements and simulate a real device.

// TODO: fully implement boot loader script

Methods

debugModeOn(showDebugOverlay)

Highlights the device by showing it's device region, screen region (if applicable), and interaction inputs (if applicable).

parameters

NameTypeDefaultDescription
showDebugOverlaybooleanfalsean overlay to show used for debugging when the device is in debug mode.

debugModeOff

Turns of any region highlighting as well as the debug overlay if it was set to show when debugMode was set to true.

setDisplay(displayNo)

Sets the current display for the device.

parameters

NameTypeDefaultDescription
displayNointeger0the display to show (indexb-based)

addActuator(actuator)

Adds an actuator to the screen object. This does not immediately add the actuator to the display area. Only a reference to signify that the actuator belongs to this device is made. The actuator is positioned and shown later in the setup method.

parameters

NameTypeDefaultDescription
actuatorJLS.actuators.{any}---the actuator to add to the device.

addBootLoader

// TODO: fully implement boot loader scripts

Adds a boot script to the device to follow when it is "powered on."

load

Passes the device's assets from the asset loader and calls the setup method to setup the display/interaction elements. If none, null value is set. Load only be called when all assets are finished loading.

boot

// TODO: boot loader script that mimicks the boot sequence of a real device

shutdown

// TODO: grace shutdown of a device -- mimicking a real device

init(displays)

Initializes the device. If intialized with displays, add displays to the object. This does not immediately show the display on the device. Only a reference is made to signify that the screen belongs to the device. Displays are positioned and shown when the setup method is called.

parameters

NameTypeDefaultDescription
displaysarray---An array of JLS.core.DeviceDisplay objects to use as the device's displays.
  • new Device(options)
  • Members
    • originRef
    • originX
    • originY
    • originW
    • originH
    • screenRegionX
    • screenRegionY
    • screenRegionW
    • screenRegionH
    • hasScreen
    • hasActuators
    • backgroundColor
    • debugMode
    • deviceState
    • isActiveDevice
    • currentDisplay
    • sprites
    • displays
    • actuators
    • resources
    • bootLoader
  • Methods
    • debugModeOn(showDebugOverlay)
    • debugModeOff
    • setDisplay(displayNo)
    • addActuator(actuator)
    • addBootLoader
    • load
    • boot
    • shutdown
    • init(displays)
Jet Link Simulations
Docs
Getting StartedGuidesAPI Reference
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Copyright © 2020 Name or Your Company Name