Sign in to follow this  

async image loader

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() {'profilepic','');}profileButtonAction:function() {        profileButton.loadTexture('profilepic');}
i want;
profileButtonAction:function() {'profilepic','');        profileButton.loadTexture('profilepic');}

or async image loader?

Please do not solve these issues

Share this post

Link to post
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;    }}

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.