Options
All
  • Public
  • Public/Protected
  • All
Menu

A SharedObject is a an object whos reference can be found at any time by any other SharedObjects.

Hierarchy

Index

Constructors

constructor

  • new SharedObject(game: Phaser.Game, x: number, y: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture, frame?: string | number): SharedObject
  • Parameters

    • game: Phaser.Game

      Reference to Phaser game used internally.

    • x: number

      X position of the object on the screen.

    • y: number

      Y position of the object on the screen.

    • Optional key: string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture

      Key of the image in the phaser cache. Optional.

    • Optional frame: string | number

      Frame of image in spritesheet. Optional.

    Returns SharedObject

Properties

Private _id

_id: number

Private _onDestroyedEventHandler

_onDestroyedEventHandler: EventHandlerHolder<IEntityDestroyedEventHandler>

Private _tags

_tags: string[]

Static Private _lastUsedId

_lastUsedId: number = -1

Accessors

Id

  • get Id(): number
  • The unique ID of this shared object.

    Returns number

OnDestroyedEvent

  • The EventHandlerHolder for the event when this sharedobject is destroyed using the Destory() method.

    Returns EventHandlerHolder<IEntityDestroyedEventHandler>

Tags

  • get Tags(): string[]
  • Gets all tags of this SharedObject.

    Returns string[]

Protected objectCache

  • Alias for Client.GameEngine.SharedObjectCache.

    Returns SharedObjectCache

Static IsLocalStorageSupported

  • get IsLocalStorageSupported(): boolean
  • Returns if the used browsers supports HTML5 LocalStorage.

    Returns boolean

Methods

AddTag

  • AddTag(tag: string): void
  • Add a tag to this SharedObject which can be used to find other SharedObjects with certain tags. Will silently fail if tag is already present on this SharedObject.

    Parameters

    • tag: string

      Tag to add.

    Returns void

Destroy

  • Destroy(): void
  • Destroys this object and removes it from the SharedObjectCache in the GameEngine Also calls all OnDestroyEventHandlers on this SharedObject.

    Returns void

Equals

  • Returns if the id of the given SharedObjects matches that of this SharedObject.

    Parameters

    • other: SharedObject

      SharedObject of whom's id to compare to.

    Returns boolean

HasTag

  • HasTag(tag: string): boolean
  • Returns if the given tag is present on this SharedObject.

    Parameters

    • tag: string

      Tag to search for.

    Returns boolean

OnUpdate

  • OnUpdate(): void
  • Executed each frame. Called internally.

    Returns void

RemoveTag

  • RemoveTag(tag: string): void
  • Remove a tag from this SharedObject. Will silently fail if tag is not present on this SharedObject.

    Parameters

    • tag: string

      Tagg to remove.

    Returns void

Static AddLocalStorageListedItem

  • AddLocalStorageListedItem(key: string, value: any): void
  • Add a value in the list with the given key in the local storage.

    Parameters

    • key: string

      Key of the list in the localStorage.

    • value: any

      Value to add to the list, will be serialized as a string.

    Returns void

Static AddLocalStorageListedItemEntry

  • AddLocalStorageListedItemEntry(key: string): void
  • Creates a emtpy string array and stores it into the LocalStorage.

    Parameters

    • key: string

      Key of the list in the localStorage.

    Returns void

Static Private GeneratedId

  • GeneratedId(): number
  • Returns number

Static GetLocalStorageItem

  • GetLocalStorageItem(key: string): any
  • Returns the value of a localy stored item.

    Parameters

    • key: string

      Key of the item in the LocalStorage.

    Returns any

Static GetLocalStorageListedItem

  • GetLocalStorageListedItem(key: string): string[]
  • Returns an item from the LocalStorage as an array of strings.

    Parameters

    • key: string

      Key of the list in the localStorage.

    Returns string[]

Static HasLocalStorageItem

  • HasLocalStorageItem(key: string): boolean
  • Returns whether an item with the given key is present in the LocalStorage.

    Parameters

    • key: string

      Key of the item in the LocalStorage.

    Returns boolean

Static RemoveLocalStorageItem

  • RemoveLocalStorageItem(key: string): void
  • Removes an item from the LocalStorage.

    Parameters

    • key: string

      Key of the item in the LocalStorage.

    Returns void

Static RemoveLocalStorageListedItem

  • RemoveLocalStorageListedItem(key: string, value: string, stopAtFirstEntry?: boolean): void
  • Removes an item from an array in the LocalStorage.

    Parameters

    • key: string

      Key of the list in the LocalStorage.

    • value: string

      Value to remove from the list.

    • Default value stopAtFirstEntry: boolean = false

      When true, will stop after finding a matching value. Will enumerate through the entire array and delete any matching value otherwise.

    Returns void

Static SetLocalStorageItem

  • SetLocalStorageItem(key: string, value: any): void
  • Add or set a value in the local storage. Will silently fail if LocalStorage is not supported by the browser.

    Parameters

    • key: string

      Key of the item in the LocalStorage.

    • value: any

      Value to store, will be serialized as a string.

    Returns void

Generated using TypeDoc