Sign in to follow this  
garry

performance issue, sprites with jumpy movement

Recommended Posts

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.
1053168891_12-9-20188-03-24PM.png.4b9868fb9a89fbac8f768ad333cf0ae9.png817079483_12-9-20188-02-45PM.png.2df0d646eb2331c69f32aba3dedea3bf.png
(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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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? :D  or is there a way to like have 1 sprite from each image and just copy that? something like that?

Share this post


Link to post
Share on other sites
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? 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.