gamvas.Resource.prototype.getImage = function( url )
Load a image from url
url | The image url |
A javascript image object, that might be not fully loaded yet
myState = gamvas.State.extend({ init: function() { this.img = this.resource.getImage('myImage.png'); }, draw: function(t) { if (this.resource.done()) { // everything loaded? // do something with this.img } else { // data is still loading // print current loading status in percent this.c.fillText("Loading... "+(100*this.resource.status())+"%", 10, 10); } } });
gamvas.Resource.prototype.getSound = function( url )
Load a sound/music file from url
url | The audio file url |
A javascript Audio object, that might be not fully loaded yet
myState = gamvas.State.extend({ create: function(name) { this._super(name); this.snd = this.resource.getSound('pling.wav'); }, draw: function(t) { if (this.resource.done()) { // everything loaded? // play the sound gamvas.sound.play(this.snd); } else { // data is still loading // print current loading status in percent this.c.fillText("Loading... "+(100*this.resource.status())+"%", 10, 10); } } });
Load a image from url
gamvas.Resource.prototype.getImage = function( url )
Load a sound/music file from url
gamvas.Resource.prototype.getSound = function( url )
Get the status of all loading resources
gamvas.Resource.prototype.status = function()
Are all resources loaded?
gamvas.Resource.prototype.done = function()