These are chat archives for pixijs/pixi.js

28th
Mar 2017
Alan
@Alan01252
Mar 28 2017 13:40 UTC
Hi all, Just wondering if I'm going horribly wrong when using Pixi. My game runs, but the performance every so often goes to pot and the browser, crashes.
I've essentially got a collection of methods that add sprites to the stage
and I clear / redraw the stage on every requestAnimationFrame
like so
Is this the right thing to be doing? Or have I lost the plot?
Any help advice/ would be apprecaited :)
Mark Knol
@markknol
Mar 28 2017 14:57 UTC
@Alan01252 im not an expert, but removing your full stage every frame can affect performance, why do you recreate everything every frame?
Alan
@Alan01252
Mar 28 2017 14:59 UTC
Yeah... I thought that ;) The problem is everything changes every frame ( other than a single sprite which is the players tank ) as the background moves around the tank to give the "driving" effect around the world
as an example
the tank always remains center of the frame, but the rocks and the lake move about based on where you currently are
( I lied earlier when I said only the tank, also the interface on the right is sticky too ;) )
what's strange is it works really well for "a while" and then dies, but can't see any memory leaks when I profile either
digibo
@digibo
Mar 28 2017 16:12 UTC
You should definitely avoid removing/adding everything on every frame, if this is what you are doing. You can add them once and then have an update function that simply changes x, y, etc.
Alan
@Alan01252
Mar 28 2017 16:14 UTC
ty :) I'll have to think about how best to do it... as it'll be an entirely different method from the code I'm porting !
digibo
@digibo
Mar 28 2017 16:16 UTC
play.js seem to do exactly this
you'll need to do something similar in draw.js
Alan
@Alan01252
Mar 28 2017 16:21 UTC
yeah, it's a bit tricky I guess how the method of drawing works as in moving around a map in this fashion... Sure it's possible to adapt it just needs some thought! :)
Alan
@Alan01252
Mar 28 2017 18:24 UTC
I've tried something a bit different, I've now got a few different containers, the rapidly changing textures are now stored in ParticleContainers
this seems to work "better" ( my cpu doesn't go mental )
still not sure if this is the right way of doing things mind you