Jump to content

Check if sprite on-screen


Punknoodles
 Share

Recommended Posts

I'm developing a multiplayer game using Phaser, Node.JS, and socket.io. The world is much bigger than the screen. To optimize this, I want to be able to not render sprites that are off-screen. How would I do this? Is there a method that checks if a sprite is on screen at its current x and y coordinates? Or even a way to check if a worldx and worldy position is on-screen?

Link to comment
Share on other sites

I think you can define your render area as the windows size, for rest sprites off screen, you just do them as normal. when they are off screen, they wont be rendered so the performance shouldn't be a problem. I bet the performance is due to your massive word especial your background. it will be challenge for gpu.  maybe you can check tilemap.

Link to comment
Share on other sites

1 hour ago, tywang2006 said:

I think you can define your render area as the windows size, for rest sprites off screen, you just do them as normal. when they are off screen, they wont be rendered so the performance shouldn't be a problem. I bet the performance is due to your massive word especial your background. it will be challenge for gpu.  maybe you can check tilemap.

How would I do that?

Link to comment
Share on other sites

I think there's a way to simplify the bounds checks if you're not scaling or rotating any ancestors (I have to find it). I can't remember why autocull would be costly, since Phaser/PIXI has to calculate each sprite's transformation anyway in order to render it.

For bullets it may be easier just to set a lifespan instead.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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