Jump to content

Couple Questions (background execution, webGL)


Recommended Posts

Hi all.  Enjoying Phaser thus far, but one primary concern I have is if the window running phaser is not in focus, phaser simply stops executing.


I know javascript doesn't halt on my system when out of focus, and I've seen other HTML5 games continue to animate (albeit at lower interval of course), but Phaser just outright stops.


Is this by design or a limitation?  Is there an obvious work around I am not seeing in the docs?


Secondly, about WebGL.


1) Is power of 2 always going to be a constraint?  I know at the hardware level it is, but many libraries have overcome the issue for end-developers... This of course is not a high priority thing, but I'm just curious (for now I just use canvas).


2) Using a tiled sprite, there is a great degree of shaking/blinking making it pretty much unusable for my current implementation.  I read (and posted to no avail) in a previous thread who said upgrading to 1.1.3 fixed the issue for him (he was talking about the examples).  For me, though, even with the latest branch it still does it when webGL is selected.


I'm on MacOS using Chrome, but the behavior is reproduced for me across every browser so far (I have VM access and can try it on any OS ever; but immediately it annoys me greatly and so I just use canvas for now :)


I'd like to use AUTO for the game object, however, for obvious reasons.  Though the power of 2 issue pretty much kills it for my game due to the way my project is designed.  I'm making a slot machine game and the "reels" scroll based on a fixed image and so the texture must be 1 icon in width and X icons in height -- and power of 2 crushes my hopes and dreams for variable reel lengths.


(Perhaps I'm lazy and shouldn't tile sprite and generate random sprites for the rolling animation; trying to be efficient here tho and maintain some realistic feel :)



Link to comment
Share on other sites

1) It's by design, but is easily stopped:

//  Phaser will automatically pause if the browser tab the game is in loses focus. You can disable that here:this.game.stage.disableVisibilityChange = true;

2) You don't need pot texture sizes anywhere in Phaser other than for Tiled Sprites. It's still sensible to stick to them though, given the way GPU texture memory is allocated.


3) The Tile Sprite GPU issue was only fixed a couple of days ago in the dev 1.1.4 branch (thanks to Mat from Pixi.js, where the issue was arising from).


4) Then I'd most likely just use 2 sprites (with the same texture) stacked on top of each other, and move them down the screen together, when one is 'off' the bottom, simply wrap it around and place it on the top of the other sprite and repeat. I'd definitely do that as opposed to 1 sprite per reel item, but I guess it depends how many items are visible at once? I suspect not a great deal, 3 or so? In which case you'd only need a really small number of sprites in total anyway.


Either that or make sure the sprites fit a pot texture size :)

Link to comment
Share on other sites

--edit, missed a part of what you said about the pot being limited to tiled sprites.


Thanks for your help on this stuff, I'll hack away and see what's what.  I'll likely just stick to Canvas though, it's not a terribly performance hungry application.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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