API Document Index



Class me.loader


Defined in: <build/melonJS-0.9.3.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
a small class to manage loading of stuff and manage resources There is no constructor function for me.input.
Field Summary
Field Attributes Field Name and Description
 
onload callback
 
onProgress callback
each time a resource is loaded, the loader will fire the specified function, giving the actual progress [0 .
Method Summary
Method Attributes Method Name and Description
 
getBinary(name)
return the specified Binary object
 
getImage(Image)
return the specified Image Object
 
Return the loading progress in percent
 
getXML(xmlfile)
return the specified XML object
 
load(resource, onload, onerror)
Load a single resource (to be used if you need to load additional resource during the game)
Given parmeter must contain the following fields :
- name : internal name of the resource
- type : "binary", "image", "tmx", "audio" - src : path and file name of the resource
 
preload(resources)
set all the specified game resources to be preloaded.
Class Detail
me.loader()
a small class to manage loading of stuff and manage resources There is no constructor function for me.input.
Field Detail
{Function} onload
onload callback
// set a callback when everything is loaded
me.loader.onload = this.loaded.bind(this);

{Function} onProgress
onProgress callback
each time a resource is loaded, the loader will fire the specified function, giving the actual progress [0 ... 1], as argument.
// set a callback for progress notification
me.loader.onProgress = this.updateProgress.bind(this);
Method Detail
{Object} getBinary(name)
return the specified Binary object
Parameters:
{String} name
of the binary object ("ymTrack");
Returns:
{Object}

{Image} getImage(Image)
return the specified Image Object
Parameters:
{String} Image
name of the Image element ("tileset-platformer");
Returns:
{Image}

{Number} getLoadProgress()
Return the loading progress in percent
Deprecated:
use callback instead
Returns:
{Number}

{Xml} getXML(xmlfile)
return the specified XML object
Parameters:
{String} xmlfile
name of the xml element ("map1");
Returns:
{Xml}

load(resource, onload, onerror)
Load a single resource (to be used if you need to load additional resource during the game)
Given parmeter must contain the following fields :
- name : internal name of the resource
- type : "binary", "image", "tmx", "audio" - src : path and file name of the resource
// load a image asset
me.loader.load({name: "avatar",  type:"image",  src: "data/avatar.png"}, this.onload.bind(this), this.onerror.bind(this));
Parameters:
{Object} resource
{Function} onload
function to be called when the resource is loaded
{Function} onerror
function to be called in case of error

preload(resources)
set all the specified game resources to be preloaded.
each resource item must contain the following fields :
- name : internal name of the resource
- type : "image", "tmx", "audio"
- src : path and file name of the resource
(!) for audio :
- src : path (only) where resources are located
- channel : number of channels to be created

var g_resources = [ {name: "tileset-platformer",  type:"image",   src: "data/map/tileset-platformer.png"},
                    {name: "map1",                type: "tmx",    src: "data/map/map1_slopes.tmx"},
                    {name: "cling",               type: "audio",  src: "data/audio/",	channel : 2},
                    {name: "ymTrack",             type: "binary", src: "data/audio/main.ym"}
					
                   ]; 
...

// set all resources to be loaded
me.loader.preload(g_resources);
Parameters:
{Array.} resources

Documentation generated by JsDoc Toolkit 2.4.0 on Tue May 01 2012 12:00:49 GMT+0800 (CST)