Jump to content

async image loader


yvzyldrm
 Share

Recommended Posts

hi there 
 
I have a problem like mine. I want to upload pictures from an address now. necessarily have to make it through, but staying in preload. Once the game starts loading can not I?
 
preload:function() {       this.game.load.image('profilepic','https://abc.com/profile.jpg');}profileButtonAction:function() {        profileButton.loadTexture('profilepic');}
i want;
 
profileButtonAction:function() {        this.game.load.image('profilepic','https://abc.com/profile.jpg');        profileButton.loadTexture('profilepic');}

or async image loader?

Please do not solve these issues

Link to comment
Share on other sites

Hi, I've done something like that and it seems to work all right so far:
 

function _fileComplete(progress, cacheKey, success, totalLoaded, totalFiles) {    if (success) this.loadTexture(cacheKey);}function dynamicLoadImage(game, x, y, url, fallback, key) {    if (typeof key === 'undefined') key = 'dynamicLoad_' + url;    if (game.cache.checkImageKey(key)) {        return game.add.image(x, y, key);    } else {        var image = game.add.image(x, y, fallback);        var loader = new Phaser.Loader(game);        loader.image(key, url);        loader.onFileComplete.addOnce(_fileComplete, image);        loader.start();        return image;    }}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...