Game Development Community

Sprites being loaded only when in camera view

by NighTerrorX · in Torque X 2D · 04/02/2009 (4:05 am) · 1 replies

Hey guys, I have checked this out for a while, but thought I would ask before I burn any more time...I am sure I am looking correctly.

I have a scene where I want to attempt 4000+ sprites on screen. I figured out the FarDistance issue....never knew that was part of it. So now my sprites stay on the screen...but now performance is my issue.

I am looking for a way to load and unload when they come into view and then leave. I have a "map" and I just try to plot the "enemies" in their location. Is there an variable I am missing already built into XNA/TorqueX (like the FarDistance to show more sprites), or has someone figured out a fancy way of doing this they are willing to share? I am drawing a blank and all my tricks are not helping my performance at all.

Thanks in advance

#1
04/10/2009 (3:46 pm)
I'm guessing when you say 4000+ sprites your talking for the level not on screen? I suppose you could have 4000+ on screen if you where taking particles into account but I'll assume you want 4000+ in a level.

Honestly I haven't gone into how torque loads scene files but I would suggest making sure you don't have components with updates in there process tick running when off screen. One thing you could do is cycle through the objects and flip bools that disable there process ticks (or the stuff in the process tick) when they are far off screen) You'll have to be carfull how often you cycle through these objects though as that in it'self could cause a performance hit.

You could also create triggers at set points in the level and spawn objects ahead of the player in code though again you'll have to be carfull with this one.

It's hard to give you exact advice without knowing what kind of game your trying to create, why you want so many objects, and what kind of object you are creating.