Cybeaer 0 Report post Posted June 13, 2017 Hi there, first i'm more or less new to JS and Pixi (comming from php), so please be patient if i ask strange questions i want to write an relative huge game/app with many locations and animations (spine maybe) and want to realize it in an one page app. To keep the memory usage low i try to write an stage/container management class that only initialize the elements (sprites/animations/dom elements) on demand and dispose them afterwards. My question is now is there allready an solution for this hidden in pixi? Or does a best practise exist for this? Or does there exist maybe even a tutorial for such a thing? Like mentioned i tried allready to write an class, but this works only for better management, but not for less memory usage or performance (app.js) And till now only adding (dom)elements and displaying them works (with resize! ) but destroying or adding the sprites in the container wont work. so any suggestions or guiding directions how to solve the many locations issue? Quote Share this post Link to post Share on other sites
ivan.popelyshev 782 Report post Posted June 13, 2017 I dont think you need optimize that much. Textures eat most of the memory space. Quote Share this post Link to post Share on other sites
Cybeaer 0 Report post Posted June 13, 2017 textures in meaning of sprite/sheets? Then i maybe just need to read myself into preloading and such a loading bar/percentage display.. then the only issue is to handle all these "sets" of stages/locations. I had an test scenery with only 4 different stages and the source was way to confusing keeping all these inside my class. And with the "class" i wrote i cant add sprites to the containers and/or hiding them. Is there some kind of library/package with which i can handle this a bit more tidy? i put myself on a limitation of max 500lines of code (+/-10%) per class Quote Share this post Link to post Share on other sites
ivan.popelyshev 782 Report post Posted June 13, 2017 If you use IDE, i recommend to write on typescript, that'll make easier to maintain the code. As for structure, there's https://github.com/pixijs/pixi-display/tree/layers that makes layer management much easier. Memory problems are hard to fight with pixi, there're tools but for each game solution is unique. I need to know how much resources do you have and which type. Quote Share this post Link to post Share on other sites
Cybeaer 0 Report post Posted June 13, 2017 i hoped i could use es6 (or was it called es2016?) i use several "ide", varied from vim to intellij. depending where i code at the moment ^^ With structure i mean i have aaaaall scenes and all sprites/animations "alive" in the code. It would be nice if i could specify some "scenes" and its content and call/use it when its needed, so i dont have to remember to which scene the dom element or sprite belongs to. Quote Memory problems are hard to fight with pixi you let my hopes shake xD Quote Share this post Link to post Share on other sites
Taz 43 Report post Posted June 13, 2017 2 hours ago, Cybeaer said: iWith structure i mean i have aaaaall scenes and all sprites/animations "alive" in the code. It would be nice if i could specify some "scenes" and its content and call/use it when its needed, so i dont have to remember to which scene the dom element or sprite belongs to. You could for example make a Container for each scene and add all the scene's sprites to its container, then to change scenes add the new scene's container to stage and remove the old scene's from stage. Then for scene transitions you could animate the containers' alpha or position or something before you remove the old scene's container, for example. Quote Share this post Link to post Share on other sites
tywang2006 11 Report post Posted June 15, 2017 make sure once texture not used, destroy them. Quote Share this post Link to post Share on other sites