Options
All
  • Public
  • Public/Protected
  • All
Menu
classdesc

Creates a DuckEngine Scene

description

The Scene Class. Main rendering happens here

since

1.0.0-beta

Hierarchy

  • Render
    • Scene

Index

Constructors

constructor

  • new Scene(key: string, game: Game, visible?: boolean): Scene
  • description

    Creates a Scene instance

    since

    1.0.0-beta

    Parameters

    • key: string

      Key/Identifier or name of scene

    • game: Game

      Game instance

    • Optional visible: boolean

    Returns Scene

Properties

add

add: { gameobject: { misc: { canvasModulate: any }; circle: any; existing: any; rect: any; roundRect: any; sprite: any }; light: { staticLight: any }; map: { tileLayer: any; tilemap: any; tileset: any }; misc: { area: any }; presetEffect: { explosionEffect: any; smokeEffect: any }; ui: { button: any; text: any }; camera: any; cutscene: any; effect: any; group: any; input: any; mainCamera: any; particle: any; particleEmitter: any; soundPlayer: any }
memberof

Scene

description

Used to add GameObjects and more to the scene

since

1.0.0-beta

Type declaration

cameras

cameras: Camera[]
memberof

Scene

description

An array of cameras that the scene holds

since

1.0.0-beta

currentCamera

currentCamera: undefined | Camera
memberof

Scene

description

The current camera being updated

since

1.0.0-beta

Readonly default

default: boolean
memberof

Scene

description

Determines if the Scene is visible by default

since

1.0.0-beta

displayList

displayList: DisplayList
memberof

Scene

description

A DisplayList instance, holds and manages Renderables

since

2.0.0

Protected game

game: Game
memberof

Scene

description

The game instance the scene is added to

since

1.0.0-beta

Readonly key

key: string
memberof

Scene

description

The key of the Scene, used to identify the Scene

since

1.0.0-beta

loader

loader: Loader
memberof

Scene

description

A Loader instance, used to load assets in Scene.preload method that you override

since

2.0.0

mainCamera

mainCamera: undefined | Camera
memberof

Scene

description

The main camera of the scene

since

1.0.0-beta

onSceneActive

onSceneActive: () => void

Type declaration

    • (): void
    • memberof

      Scene

      description

      A property that is a function that gets called when the scene is switched to being visible

      since

      2.1.0

      Returns void

onSceneInactive

onSceneInactive: () => void

Type declaration

    • (): void
    • memberof

      Scene

      description

      A property that is a function that gets called when the scene is switched to not being visible

      since

      2.1.0

      Returns void

physicsList

physicsList: PhysicsList
memberof

Scene

description

A PhysicsList instance, holds and manages PhysicsBodies

since

2.0.0

physicsServer

physicsServer: undefined | PhysicsServer
memberof

Scene

description

A PhysicsServer instance, manages and updates all the physics for the Scene.PhysicsList. It is set to undefined if Game.config.physics.customTick is truthy

since

2.0.0

tools

tools: { color: { convert: { hex: { toHsl: any; toRgb: any; toRgba: any }; rgb: { toHsl: any; toRgba: any }; rgba: { toHsla: any; toRgb: any } }; is: { hex: any; hsl: any; rgb: any }; random: any; randomWithAlpha: any }; loader: typeof Loader; math: { vector: typeof Vector2; clamp: any; createVector: any; lerp: any; randomFloat: any; randomInt: any }; physics: { circleToRectIntersect: any; rectToRectIntersect: any } }
memberof

Scene

description

Misc tools, contains color, physics, and math related tools

since

1.0.0-beta

Type declaration

  • color: { convert: { hex: { toHsl: any; toRgb: any; toRgba: any }; rgb: { toHsl: any; toRgba: any }; rgba: { toHsla: any; toRgb: any } }; is: { hex: any; hsl: any; rgb: any }; random: any; randomWithAlpha: any }
    • convert: { hex: { toHsl: any; toRgb: any; toRgba: any }; rgb: { toHsl: any; toRgba: any }; rgba: { toHsla: any; toRgb: any } }
      • hex: { toHsl: any; toRgb: any; toRgba: any }
        • toHsl:function
          • toHsl(hex: string): string
        • toRgb:function
          • toRgb(hex: string): null | string
        • toRgba:function
      • rgb: { toHsl: any; toRgba: any }
        • toHsl:function
          • toHsl(r: number, g: number, b: number): string
        • toRgba:function
      • rgba: { toHsla: any; toRgb: any }
        • toHsla:function
          • toHsla(r: string | number, g: string | number, b: string | number, a: AlphaRange): string
        • toRgb:function
          • toRgb(rgba: string): string
    • is: { hex: any; hsl: any; rgb: any }
      • hex:function
        • hex(str: string): boolean
      • hsl:function
        • hsl(str: string): boolean
      • rgb:function
        • rgb(str: string): boolean
    • random:function
      • random(): string
    • randomWithAlpha:function
  • loader: typeof Loader
  • math: { vector: typeof Vector2; clamp: any; createVector: any; lerp: any; randomFloat: any; randomInt: any }
    • vector: typeof Vector2
    • clamp:function
      • clamp(x: number, min: number, max: number): number
    • createVector:function
      • createVector(x?: number, y?: number): Vector2
    • lerp:function
      • lerp(start: number, end: number, amount: number): number
      • Parameters

        • start: number
        • end: number
        • amount: number

        Returns number

    • randomFloat:function
      • randomFloat(min: number, max: number, fixed?: number): number
      • Parameters

        • min: number
        • max: number
        • Optional fixed: number

        Returns number

    • randomInt:function
      • randomInt(min: number, max: number): number
  • physics: { circleToRectIntersect: any; rectToRectIntersect: any }
    • circleToRectIntersect:function
      • circleToRectIntersect(circle: Circle | { h: number; position: { x: number; y: number }; r: number; w: number }, rect: Sprite | Rect | { h: number; position: { x: number; y: number }; w: number }): boolean
      • Parameters

        • circle: Circle | { h: number; position: { x: number; y: number }; r: number; w: number }
        • rect: Sprite | Rect | { h: number; position: { x: number; y: number }; w: number }

        Returns boolean

    • rectToRectIntersect:function

visible

visible: boolean
memberof

Scene

description

The state of the Scene being visible, determines if the Scene.displayList, physicsList, update, and __tick, is being called/used in the game loop

since

1.0.0-beta

Methods

__tick

  • __tick(): void
  • memberof

    Scene

    description

    Calls physics server __tick method if game.config.physics.enabled is true and game.config.physics.customTick is false Do not call manually, this is called in GAME LOOP

    since

    2.0.0

    Returns void

createTimer

  • createTimer(ms: number, cb: (...args: unknown[]) => unknown, args: unknown[], repeat: number): default
  • memberof

    Scene

    description

    Creates and returns a Timer instance

    since

    2.1.0

    Parameters

    • ms: number

      Milliseconds, converted to seconds which is used to check if the target time is reached in Timer.count

    • cb: (...args: unknown[]) => unknown

      Callback to call every time the timer reaches its target

        • (...args: unknown[]): unknown
        • Parameters

          • Rest ...args: unknown[]

          Returns unknown

    • args: unknown[]

      Arguments to pass to the callback

    • repeat: number

      Amount of times to repeat, set to infinity to repeat forever

    Returns default

once

  • once(func: (...args: unknown[]) => unknown, run?: boolean): default
  • memberof

    Scene

    description

    Runs a function once no matter if it is in a loop or not

    since

    1.0.0

    Parameters

    • func: (...args: unknown[]) => unknown

      Function to run

        • (...args: unknown[]): unknown
        • Parameters

          • Rest ...args: unknown[]

          Returns unknown

    • Optional run: boolean

    Returns default

runAmount

  • runAmount(func: (currentCount: number) => void, maxAmount: number, run?: boolean): default
  • memberof

    Scene

    description

    Allows a function to only be ran a max amount of times

    since

    1.1.0

    Parameters

    • func: (currentCount: number) => void

      Function to call

        • (currentCount: number): void
        • Parameters

          • currentCount: number

          Returns void

    • maxAmount: number

      Max amount of times to allow the function to be called

    • Optional run: boolean

    Returns default

setMainCamera

  • setMainCamera(camera: Camera): void
  • memberof

    Scene

    description

    Sets a camera as the main camera

    since

    1.0.0-beta

    Parameters

    • camera: Camera

      Camera to set the main camera as

    Returns void

setVisible

  • setVisible(visible: boolean): void
  • memberof

    Scene

    description

    Sets the visible property and calls the game.renderer.pipeline.pool method to immediately update the visibility

    Note: this calls Game.renderer.pipeline.pool to immediately update the visibility

    since

    2.1.0

    Parameters

    • visible: boolean

      What to set the visible property to

    Returns void

switchCamera

  • switchCamera(camera: Camera): void
  • memberof

    Scene

    description

    Switches the active camera to a passed camera

    memberof

    1.0.0-beta

    Parameters

    • camera: Camera

      Camera to switch to

    Returns void

switchToMainCamera

  • switchToMainCamera(): void
  • memberof

    Scene

    description

    Switches the active camera to the main camera

    since

    1.0.0-beta

    Returns void

Generated using TypeDoc