Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Switcher

Represents a switcher object that allows players to switch between different objects. Created using GameObject.createSwitcher and accessed using GameObject.getSwitcher

Hierarchy

  • Switcher

Index

Properties

onObjectSwitched

onObjectSwitched: MulticastDelegate<(switcher: this, newIndex: number, oldIndex: number) => void>

Called when the active object has changed

param

The switcher for which the change happened

param

The new active index

param

The previous active index. Can be equal to new index if an object was deleted from the switcher and the object at this index changed, or if a player switches to a random state which turns out to be the same state as before.

Methods

addObjects

  • addObjects(objects: GameObject[], index?: number, showAnimation?: boolean): void
  • Add an array of objects to the switcher. If objects are in a container, card holder, or another switcher, they will not be added.

    Parameters

    • objects: GameObject[]

      Objects to add

    • Optional index: number

      The index at which the new objects will be added. By default, they will be inserted at start (index 0)

    • Optional showAnimation: boolean

      If false, don't show insert animation. Default: false

    Returns void

contains

destroy

  • destroy(): void
  • Remove this switcher, leaving the active object as a regular object

    Returns void

getCurrentObject

getCurrentObjectIndex

  • getCurrentObjectIndex(): number
  • Return the index of the currently active object

    Returns number

getNumObjects

  • getNumObjects(): number
  • Return the number of objects in the switcher

    Returns number

getObjectAt

isValid

  • isValid(): boolean
  • Return whether the switcher object is valid. A switcher becomes invalid after it has been destroyed explicitly, or if the current object is deleted.

    Returns boolean

remove

  • Remove an object from the switcher and delete it. Only deletes the object if it was in the switcher, and returns whether it was deleted.

    Parameters

    Returns boolean

removeAt

  • removeAt(index: number): boolean
  • Remove an object from the switcher and delete it. Returns whether something was removed.

    Parameters

    • index: number

      The index of the object to remove

    Returns boolean

setObjectIndex

  • setObjectIndex(index: number): void
  • Set the index of the active object

    Parameters

    • index: number

    Returns void