Jet Link Simulations

Jet Link Simulations

  • Docs
  • API Reference
  • Help

BaseContainer

The base container is intended to be used by extending it on the creation of new Screens, Devices, Instruments, Elements and any thing else that needs to have access to base utility functions on the class instance.

When accessing assets from the shared asset loader, the asset manager prefixes global and local to the key used when the asset was set. "global" and "local" in this context refer to the whether an asset is a part of the object's resources and is not be confused with scope.

All assets set in the shared asset manager (SAM) are accessible globally. Auto-generated sprites are automatically given a prefix of the creating object's originRef and is best practice to use that object's resources only and not share resources for various Screen/Device/Instrument/ Elements.

JLS.core.BaseContainer

MyContainer extends BaseContainer

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

  class MyContainer extends BaseContainer {
    // code ommitted for brevity
  }

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.

objState

A string that can be set to determine what "state" the object is in at runtime.

sprites

A collection of local assets that only the object can see and use.

Methods

setOriginRef(ref)

Sets the origin reference of the object with a unique id. Returns the current originRef of the object as a convenience method to ensure correct unique id has been set.

parameters

NameTypeDefaultDescription
refstringthis.originRefunique reference for this object.

setOrigin(x, y)

Sets the "origin" or position of the object. Returns the current position after it has been set to the object as a convenience method to ensure correct origin has been set. This method should be used after add items to a container or unexpected behavior can occur.

parameters

NameTypeDefaultDescription
xnumberthis.originXposition relative to the parent container.
ynumberthis.originYposition relative to the paraent container.

setDimensions(w, h)

Sets the size of the object. Returns the current size of the object as a convenience method to ensure correct origin has been set.

parameters

NameTypeDefaultDescription
wnumberthis.originWwidth of the object.
hnumberthis.originHheight of the object.

setObjectState(state)

Sets the state of the object.

parameters

NameTypeDefaultDescription
statestring---an arbitrary value that can be set as "state".

setAlpha(value, object)

Sets the alpha (opacity) of the container. If wished to hide and not have any interactivity with the object. setVisibility method should be used instead.

parameters

NameTypeDefaultDescription
valuefloat---the opacity from 0-1. 1 having no transparency.
objectPIXI object (i.e.: Container, Graphic, etc.)---the PIXI display object to set alpha property.

setVisibility(value, object)

Sets the visibility of a pixi display object. Method can be used to toggle visibility of a child element or the parent container if this is passed as the object. If visibility is set to 0, the object will not be able to be interacted with. If interactivity is desired, use setAlpha method instead.

parameters

NameTypeDefaultDescription
valueinteger---the value (0 or 1) to set. 1 is visible, 0 is not.
objectPIXI object (i.e.: Container, Graphic, etc.)---the PIXI display object to set visible property.

setBackground(fillColor, options)

Add a colored region that spans the entire area of the container it is called on. forceToBack option shifts it's position as the first child in the container which places all the children above it making it a "background." By setting forceToBack false, it is added as normal at the next index available.

parameters

NameTypeDefaultDescription
fillColorstring---the hexcode to set (i.e.: "000000").
optionsobject---see options and their defaults below.

options

NameTypeDefaultDescription
lineColorstringnullthe color hexcode to set (i.e.: "000000") as the shape's border.
lineThicknessnumbernullthe stroke of the shape's border.
bevelsnumbernullthe border radius of the shape.
opacityfloat1.0the opacity of the shape.
forceToBackbooleantruemakes the shape the first "layout" in the stack so all other objects appear infront of it.

makeInteractive(buttonMode, object)

Makes the object able to trigger events when interacted with. Able to specify the PIXI display object; If none provided, the container that called the method is made interactive.

parameters

NameTypeDefaultDescription
buttonModebooleanfalseenable cursor change on hover (desktop only).
objectPIXI Object (i.e.: Container, Graphic)---the PIXI object to make interactive.
  • MyContainer extends BaseContainer
  • Members
    • originRef
    • originX
    • originY
    • originW
    • originH
    • objState
    • sprites
  • Methods
    • setOriginRef(ref)
    • setOrigin(x, y)
    • setDimensions(w, h)
    • setObjectState(state)
    • setAlpha(value, object)
    • setVisibility(value, object)
    • setBackground(fillColor, options)
    • makeInteractive(buttonMode, object)
Jet Link Simulations
Docs
Getting StartedGuidesAPI Reference
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Copyright © 2020 Name or Your Company Name