Jump to content

performance issue, sprites with jumpy movement


garry
 Share

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

Link to comment
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?

Link to comment
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? 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...