Punknoodles

Check if sprite on-screen

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?

Share this post


Link to post
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.

Share this post


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

Share this post


Link to post
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.

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.