Quick answer: Set Texture Groups to Load on game start. For audio, call audio_sound_set_track_position(snd, 0) on each clip during a loading screen. For sprites used the first time mid-gameplay, draw them once off-screen at room start.
First time the player encounters a new enemy, frame drops by 50ms. Texture for the enemy’s sprite uploaded mid-frame. The fix is to preload during loading screens, not during gameplay.
The Symptom
One-frame stutter the first time you spawn a new sprite, play a new sound, or trigger a new particle effect. Subsequent uses are smooth.
The Fix
Step 1: Texture Group prefetch. Project Settings → Texture Groups. For each group, tick “Load on game start.” The group’s textures upload to GPU during boot.
// Or per-group at runtime
texturegroup_load("tg_combat"); // preload combat textures
Free at scene-end with texturegroup_unload if memory is constrained.
Step 2: Audio preload.
/// In a loading-screen room or on game start
var all_sounds = [snd_explosion, snd_pickup, snd_jump, snd_die];
for (var i = 0; i < array_length(all_sounds); ++i) {
var s = all_sounds[i];
// touching the sound forces decode
audio_sound_set_track_position(s, 0);
}
Step 3: Sprite warm-up draws. For sprites that aren’t in a preloaded group:
/// In a one-time warm-up state
for (var i = 0; i < array_length(warm_sprites); ++i) {
draw_sprite(warm_sprites[i], 0, -10000, -10000); // off-screen
}
The off-screen draw uploads the texture. Subsequent draws are cheap.
Profile First
Use the Debug Overlay (F8 in IDE) or fps_real to measure where the hitch lives. Don’t blanket-preload everything — just the assets that show first-touch latency in your hot paths.
Verifying
Add a Debug.Log of the frame time during the previously-stuttering moment. Should drop to normal after preload. If still hitching, the asset isn’t in the preloaded set.
“Texture Groups loaded at start. Audio touched. Sprites warmed off-screen. Cold paths warm up.”
Related Issues
For surface lost on resize, see surface lost. For instance deactivate, see deactivate region.
Pay the cost during loading. Smooth gameplay.