Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Asset

Hierarchy

  • Asset

Index

Constructors

constructor

  • public constructor Asset

    Represents an asset to a game.
    

    Parameters

    • type: AssetType

      Enumeration

    • Optional url: string

      Location path.

    Returns Asset

Properties

Private _attributes

_attributes: object

Type declaration

  • [key: string]: any

Private _data

_data: Object

Private _id

_id: string

Private _loadStrategy

_loadStrategy: AssetLoader

Private _state

_state: AssetState

Private _type

_type: AssetType

Private _url

_url: string

Methods

getAttribute

  • getAttribute(key: string): any
  • public getAttribute

    Gets data details from this asset.
    

    Parameters

    • key: string

    Returns any

getData

  • getData(): any

getLoadStrategy

getSource

  • getSource(): string
  • public getSource

    Returns the source location path of this asset.
    

    Returns string

getState

getType

isAttribute

  • isAttribute(key: string): boolean
  • public isAttribute

    Checks for existance of a data detail on this asset.
    

    Parameters

    • key: string

    Returns boolean

isReady

  • isReady(): boolean
  • public isReady

    Checks to see if the data has been loaded on this asset.
    

    Returns boolean

load

  • load(): void
  • public load

    Loads the asset data.
    
    Use onDataChange hook method to get notified when data has
    finished loading.
    

    Returns void

onDataChange

  • onDataChange(data: Object): void
  • public onDataChange

    Invoked when data changes.
    

    Parameters

    • data: Object

      Must be prepared to handle null.

    Returns void

onError

  • onError(error?: Object): void
  • public onError

    Invoked when there was an error while loading asset data.
    

    Parameters

    • Optional error: Object

    Returns void

onStateChange

  • public hook onStateChange

    Invoked when state changes.
    

    Parameters

    • state: AssetState

      Possible values: zen.assets.Asset.NOT_LOADED zen.assets.Asset.LOADING zen.assets.Asset.LOADED

    Returns void

removeAttribute

  • removeAttribute(key: string): void
  • public removeAttribute

    Removes a data attribute from this asset.
    

    Parameters

    • key: string

    Returns void

setAttribute

  • setAttribute(key: string, value: any): void
  • public setAttribute

    Sets data details for this asset.
    

    Parameters

    • key: string
    • value: any

    Returns void

setData

  • setData(data: Object): void
  • public setData

    Sets the data for this asset.
    

    Parameters

    • data: Object

    Returns void

setLoadStrategy

  • public setLoadStrategy

    Sets the strategy class to be used for loading
    

    Parameters

    Returns void

setSource

  • setSource(source: string): void
  • public setSource

    Sets the source location path of this asset.
    This will clear the associated data, and set this asset in the
    NOT_LOADED state.
    

    Parameters

    • source: string

    Returns void

setState

  • public setState

    Sets the state of this asset.
    
    To be used internally only.
    

    Parameters

    Returns void

Generated using TypeDoc