ForgeableSum Posted April 15, 2017 Share Posted April 15, 2017 Is there anyway to perform DOM manipulation while phaser is loading or resetting a state? I noticed the DOM is completely frozen when loading/resetting a state. I'd like to do various DOM stuff during that time, like showing when each player in the game has completed loading. Link to comment Share on other sites More sharing options...
mattstyles Posted April 17, 2017 Share Posted April 17, 2017 Not sure how you're managing to 'freeze' the DOM, if you're performing heavy synchronous calculations during a load/reset then this will occupy the JS thread, meaning that any JS animations will cease and responding to any actions will become impossible (to solve that you'd need a scheduler, not an easy task!). If you're just loading assets then these won't block, JS is event driven so it initiates a network event to load stuff and responds to an event when it finishes. Conceptually you just need to attach listeners to your load events i.e. you load all the assets for Player A and listen for the finished event and then you could create an image element on the page (or a sprite in a canvas) with an image you've just loaded. Pretty sure Phaser makes this trivial by exposing load events. snowbillr 1 Link to comment Share on other sites More sharing options...
Recommended Posts