Jump to content

Load assets asynchronously on the run


soylomass
 Share

Recommended Posts

Hi, is it possible to load assets on the run, and show them on a sprite when they are loaded?

I'm developing a team feature, where a team (and it's logo) may have been created after the game was loaded (therefore I can't load it's texture on preload).

I've seen other canvas games which do that, for example Agar.io (http://agar.io/). You can check the chrome console, Network tab, filter by Img, and you'll see the images are loaded as a player using them appears on screen. This is all seamless.

Is it possible to do with Phaser?

 

Thanks in advance.

Link to comment
Share on other sites

The standard loader can be used as many times as you want (I think), you'd just listen for the load events and start displaying the corresponding sprites when you hear it.

The process is the same with any browser load, request the asset, listen for the onLoad/onComplete event, respond using the loaded asset, handle failures.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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