kaplay
kaplay copied to clipboard
fix: perf optimization for the shooter game kaplayground example
Someone mentioned under my KAPLAY in 5 mins video that the performance of the shooter example would degrade after 20s if they increased the trash spawn rate to 0.1.
After investigation, I noticed that the offscreen component was not being used, therefore trash game objects would not be destroyed once they fall outside the screen. Since we continually add trash game objects in this game, this would lead to degraded performance over time.
The fix is simple, use the offscreen() component.
That someone was me. 🙂 Implementing this change didn't fix my performance problems, but it still feels like a good addition to the demo.