garry Posted December 9, 2018 Share Posted December 9, 2018 I have a performance issue (using pixi 4.8.2 , i've also tried other versions) I creat some sprites *fromImage* and moving them toward an angle simply like this: sprite.x += 1 * Math.cos(sprite.rotation - 90 * (Math.PI / 180)); sprite.y += 1 * Math.sin(sprite.rotation - 90 * (Math.PI / 180)); they all have a same 1kb image, when the sprites count goes higher than like 1000 their movement start becoming jumpy (they slow down then suddenly they move faster - no lag) I tried particle container but nothing changed. and btw there is no frame drop, always 60. (don't mind the timer, it's from something else, i disabled it and tested, it had nothing to do with this issue) Any idea what is the problem? (testing this on a core-i3, 4gb ram computer) Thanks Quote Link to comment Share on other sites More sharing options...
garry Posted December 10, 2018 Author Share Posted December 10, 2018 turns out this jumpy movement happens when some other sprites get destroyed (sprites get destroyed after couple of seconds). i destroy them like this: container.removeChild(theChild) what can i do here to solve this issue? Quote Link to comment Share on other sites More sharing options...
bubamara Posted December 10, 2018 Share Posted December 10, 2018 Usually you don't want to be creating and removing sprites in the main loop. Better would be to create pool of sprites ahead, making them invisible when they are not needed (theChild.visible = false) and visible again later on Quote Link to comment Share on other sites More sharing options...
garry Posted December 10, 2018 Author Share Posted December 10, 2018 29 minutes ago, bubamara said: Usually you don't want to be creating and removing sprites in the main loop. Better would be to create pool of sprites ahead, making them invisible when they are not needed (theChild.visible = false) and visible again later on yea I thought about making a pool but there is a problem: when i said that all the sprites have a same image that was not entirely true, I tried all the sprites with 1 images and the problem was not coming from that so that is why i just said they use 1 same image. there are about 100 images for sprites and at a time there might be up to 2000 sprites with a same image (although the max sprite count is not higher than 2k) so for making a pool i should put 200k sprites invisible somewhere? or is there a way to like have 1 sprite from each image and just copy that? something like that? Quote Link to comment Share on other sites More sharing options...
bubamara Posted December 10, 2018 Share Posted December 10, 2018 no, create a poll of sprites with same texture and just reasign textue to what you need when it becomes visible garry 1 Quote Link to comment Share on other sites More sharing options...
garry Posted December 10, 2018 Author Share Posted December 10, 2018 39 minutes ago, bubamara said: no, create a poll of sprites with same texture and just reasign textue to what you need when it becomes visible uhhh why didn't I think of that... thanks I'll just do that btw moving them to somewhere out of view would be a more efficient way or just making them invisible? Quote Link to comment Share on other sites More sharing options...
bubamara Posted December 10, 2018 Share Posted December 10, 2018 making them invisible is enough garry 1 Quote Link to comment Share on other sites More sharing options...
Exca Posted December 10, 2018 Share Posted December 10, 2018 Invisible is better than moving them outside. Items with visible = false do not update their transformations during the main loop. Items that are outside of the screen do, and they also get their rendering called if there's no culling implemented. garry and themoonrat 1 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.