loader.Asset

typedef Asset

object

an asset definition to be used with the loader

// PNG tileset
{name: "tileset-platformer", type: "image",  src: "data/map/tileset.png"}
// PNG packed texture
{name: "texture", type:"image", src: "data/gfx/texture.png"}
// PNG base64 encoded image
{name: "texture", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."}
// TSX file
{name: "meta_tiles", type: "tsx", src: "data/map/meta_tiles.tsx"}
// TMX level (XML & JSON)
{name: "map1", type: "tmx", src: "data/map/map1.json"}
{name: "map2", type: "tmx", src: "data/map/map2.tmx"}
{name: "map3", type: "tmx", format: "json", data: {"height":15,"layers":[...],"tilewidth":32,"version":1,"width":20}}
{name: "map4", type: "tmx", format: "xml", data: {xml representation of tmx}}
// audio resources
{name: "bgmusic", type: "audio",  src: "data/audio/"}
{name: "cling",   type: "audio",  src: "data/audio/"}
// base64 encoded audio resources
{name: "band",   type: "audio",  src: "data:audio/wav;base64,..."}
// binary file
{name: "ymTrack", type: "binary", src: "data/audio/main.ym"}
// JSON file (used for texturePacker)
{name: "texture", type: "json", src: "data/gfx/texture.json"}
// JavaScript file
{name: "plugin", type: "js", src: "data/js/plugin.js"}
// Font Face
{ name: "'kenpixel'", type: "fontface",  src: "url('data/font/kenvector_future.woff2')" }
// video resources
{name: "intro", type: "video",  src: "data/video/"}
See:

Summary


Properties from Asset

Public Properties


autoplay loader.js:161
static autoplay: boolean = false

boolean

Set to true to automatically start playing audio or video when loaded or added to a scene (using autoplay might require user iteraction to enable it)

data loader.js:161
static data: string

string

TMX data if not provided through a src url

loop loader.js:161
static loop: boolean = false

boolean

Set to true to automatically loop the audio or video when playing

name loader.js:161
static name: string

string

name of the asset

src loader.js:161
static src: string

string

path and/or file name of the resource (for audio assets only the path is required)

stream loader.js:161
static stream: boolean = false

boolean

Set to true to not to wait for large audio or video file to be downloaded before playing.

type loader.js:161
static type: string

string

the type of the asset ("audio"|"binary"|"image"|"json"|"js"|"tmx"|"tmj"|"tsx"|"tsj"|"fontface"|"video")


Powered by webdoc!