Sign in to follow this  
jamessimo

In-game loading bar

Recommended Posts

Hey guys, I have made a game that needs to parse and render large save files. 


The issue I have is that whiles the javascript in Phaser is doing its thing all I can do is show a gif spinner in html whiles the player waits for the game to load. 

I would like to show a progress bar, I have made a global var that basically ticks up at key intervals in the loading process. The problem is is that the number does increment however the UI in phaser does not update as well as the HTML (in html I just made a update tick and read the loadingProgress var every tick) . 

I have tested this using debug.text, html span and a phaser ext object. My entire game just locks up when processing stuff but I would like a hook that could be independent and update a number at core intervals. 

Share this post


Link to post
Share on other sites
8 minutes ago, Adel said:

Hi,

You can watch the loading progress using setPreloadSprite and onFileComplete signal from Phaser.Loader.

If you want to watch the files loading progress before the page onload event try pace or nprogress.

Hi Adel, I use setPreload sprite when loading all my assets. My issue is not loading assets, its after my game has loaded everything but has a very heavy load function internally (math mathematical calculations and bitmap rendering) 

Share this post


Link to post
Share on other sites

Cheers @samme, I think I will have to break up my monster function and break it up into chunks. Would having somthing like this be ok? 

 

init(){

loading++

 setTimeout(){function(){
//Do massive task 
loading++;
},0}


 setTimeout(){function(){
//Do another massive task 
loading++;
},100}

 setTimeout(){function(){
//Do another! another massive task 
loading++;
},200}

}

update(){
//update UI with var loading
}

 

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.