kaplay icon indicating copy to clipboard operation
kaplay copied to clipboard

fix: perf optimization for the shooter game kaplayground example

Open JSLegendDev opened this issue 4 months ago • 2 comments

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.

JSLegendDev avatar Aug 13 '25 20:08 JSLegendDev

Open in StackBlitz

npm i https://pkg.pr.new/kaplayjs/kaplay@875

commit: 6ae8202

pkg-pr-new[bot] avatar Aug 13 '25 20:08 pkg-pr-new[bot]

That someone was me. 🙂 Implementing this change didn't fix my performance problems, but it still feels like a good addition to the demo.

awulkan avatar Aug 14 '25 08:08 awulkan