Jet Link Simulations

Jet Link Simulations

  • Docs
  • API Reference
  • Help

DisplayEngine

Creates the renderer and root container. Optionally, a root container can be specified.

JLS.engines.DsiplayEngine

class DisplayEngine(options)

    // Implementation example
    import { DisplayEngine, GameEngine } from 'path/to/engines'
    import { Screen } from 'path/to/core'


    const displayEngine     = new DisplayEngine({
        width               : 1920,
        height              : 1080,
        fallbackBgColor     : 'FFFFFF',
        scaleBoxBgColor     : 'FFFFFF',
        canvasScaling       : 'autoScale',
        allowScaleDown      : true,
    })

    const TestScreen        = new Screen()

    // Set a shared display (optional)
    DisplayEngine.setShared(displayEngine)


    // Below Methods called later, usually when all assets finished loading
    // If no assets, load can be called manually


    // Set a screen to be the main container for the "scene."
    // This will usually be a JLS.Screen, but can be any PIXI.Container object
    displayEngine.set(TestScreen)

    // Begin rendering the display. This is the most important step!!! If this isn't done,
    // you won't see anything because it is not continously rendering anything.
    GameEngine.register(displayEngine.render)

options

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

See PIXI.Renderer for list of options. Only custom and commonly used options are shown here.

NameTypeDefaultDescription
autoDensitybooleantrueoptional Resizes renderer view in CSS pixels to allow for resolutions other than 1.
antialiasbooleantrueoptional Sets antialias. If not available natively then FXAA antialiasing is used.
displayAreastringfilloptional Where to display the canvas. Fill with remove all HTML body elements and only one canvas element will be shown. Another option is to specify the id of the element to use.
scaleBoxBgColorstring090E14optional The color of the area not completely filled by the canvas when scaling.
canvasScalingstringfixedoptional options: fixed, auto, autoScale Fixed applies no scaling, auto scales, but doesn't resize, autoScale scales and resizes in center of screen.
autoResizebooleantrueoptional Whether to resize the canvas if the browser width/height changes after it is setup.
allowScaleDownbooleantrueoptional Whether to allow the canvas to be smaller than it's originW and originH.
canvasPaddingnumber10optional Padding around the canvas.
disableContextMenubooleantrueoptional Whether to disable the default right click browser mouse options context menu.

Members

get static

Reference to the renderer's canvas element.

view

Get the shared instance of the class that is used.

Methods

setRootDisplay(displayObj)

Sets the root display container that's rendered. If none is passed as a parameter. An empty PIXI.Container is created and used.

parameters

NameTypeDefaultDescription
displayObjPIXI.DisplayObjectPIXI.ContainerThe container to use as a stage for rendering everything else.

set(displayObj)

Alias of setRootDisplay.

render(delta)

Renders the current stage.

setShared(obj) static

Sets the shared instance to use between classes.

parameters

NameTypeDefaultDescription
objPIXI.DisplayObjectPIXI.ContainerThe container to use as a stage for rendering everything else.

screen()

Reference to the renderer's screen rectangle. Its safe to use as filterArea or hitArea for the whole screen.

resize()

Resize the to the desired scaling method. Sets a scale factor, which is useful for adjusting child elements or other graphics to match the appropriate scale. Scaling options: (1) auto, centers canvas both horizontally/vertically; (2) autoScale, centers canvas both horizontally/vertically and scales to fit.

parameters

NameTypeDefaultDescription
autoResizebooleantrueAllows the display to adjust to the screen's size.

init()

Initializes the display engine (called automatically) on construction.

  • class DisplayEngine(options)
  • Members
    • get static
    • view
  • Methods
    • setRootDisplay(displayObj)
    • set(displayObj)
    • render(delta)
    • setShared(obj) static
    • screen()
    • resize()
    • init()
Jet Link Simulations
Docs
Getting StartedGuidesAPI Reference
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Copyright © 2020 Name or Your Company Name