Class: Asset

Asset(options)

Asset is the base class for graphical assets. Assets are used with Scene, Entity etc. They are loaded as a HTML element 'img' tag.

Constructor

new Asset(options)

Create a new Asset with the specified options
Parameters:
Name Type Description
options object The options object for the Asset - see below
Source:
Example
const { Asset } = require('tenkai')

var asset = new Asset({
  name: 'tilesAsset',
  src: 'assets/tileset.png'
})

Methods

load(callback)

Load the Asset asynchronously from its src and optionally trigger the supplied callback when available.
Parameters:
Name Type Default Description
callback function null The callback function to invoke when the asset has been loaded
Source:
Example
asset.load((err, as) => {
  console.log("Asset "+as.name+" Loaded")
})