These are chat archives for pixijs/pixi.js

Mar 2017
Mar 28 2017 13:40
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
Mar 28 2017 14:57
@Alan01252 im not an expert, but removing your full stage every frame can affect performance, why do you recreate everything every frame?
Mar 28 2017 14:59
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
Mar 28 2017 16:12
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.
Mar 28 2017 16:14
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 !
Mar 28 2017 16:16
play.js seem to do exactly this
you'll need to do something similar in draw.js
Mar 28 2017 16:21
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! :)
Mar 28 2017 18:24
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