Options
All
  • Public
  • Public/Protected
  • All
Menu

An Entity is an object that is present in the game view. This can be anything like the player, an enemy, a platform or a background. This should not be used if the sprite should have physics behaviour. In that case, use PhysicsEntity instead.

Hierarchy

Index

Constructors

constructor

  • new Entity(game: Phaser.Game, x: number, y: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture, frame?: string | number): Entity
  • 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 Entity

Properties

Protected _children

_children: Phaser.Sprite[]

game

Accessors

Id

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

    Returns number

OnDestroyedEvent

Tags

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

    Returns string[]

children

  • get children(): Phaser.Sprite[]
  • Returns all the children of this entity.

    Returns Phaser.Sprite[]

Protected objectCache

scale

  • set scale(scale: Phaser.Point): void
  • Set the scale of this entity and all it's children.

    Parameters

    • scale: Phaser.Point

    Returns void

Static IsLocalStorageSupported

  • get IsLocalStorageSupported(): 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

AttachChild

  • AttachChild(child: Phaser.Sprite): Phaser.Sprite
  • Attaches the given child to this object. This is not the same as using addChild(child). This entities scale will be applied to the child when calling this method. Returns the added child.

    Parameters

    • child: Phaser.Sprite

      Sprite to child.

    Returns Phaser.Sprite

Destroy

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

    Returns void

DetachChild

  • DetachChild(child: Phaser.Sprite): Phaser.Sprite
  • Removes the given child from this object's children. Will silently fail if the object is not a child of this entity.

    Parameters

    • child: Phaser.Sprite

      Child to remove.

    Returns Phaser.Sprite

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

IndexDependencies

  • Add requests to load sprite or spritesheets used for this entity on startup.

    Parameters

    Returns void

OnStart

  • OnStart(): void
  • Called by the game state in the create() method. Assets requested in the IndexDependencies method are loaded at this point.

    Returns void

OnUpdate

  • OnUpdate(): void
  • Called 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 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