Preloading questions

0 favourites
  • 8 posts
  • I am aware of the need to preload audio now. I just have a few questions as to how to go about it.

    If I have, say, 30-40 sound effects, what would be the best way to preload them?

    I have an 'intro screen' of sorts warning players to use Chrome to play the game which goes for about 7 seconds. Then there is the menu and of course from the menu the game can be accessed. However there are probably about 20 or so sound effects that I know will never be used in the first level and the game always progresses linearly, starting from level 1.

    Any suggestions?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'd say don't preload anything, except maybe the 1 or 2 most commonly played sound effects (e.g. player's gun firing, first explosion sound). There'll be a little bit of latency on some sound effects on the first play, but it probably won't be very noticable if there's no latency on the preloaded gun/explosion/etc. Then, on all subsequent plays the game is cached so everything will play instantly anyway (making the preloads redundant).

    There was a bug reported that seemed to be the browser choking if too many sounds were preloaded at once, so I really wouldn't try to preload everything.

    So preloads are just really for the first play. I guess you could also preload one or two extra sounds on the start of each level as you progress through the game to keep the latency less noticable.

  • All right, thanks.

  • Sorry to bump but uh..

    There'll be a little bit of latency on some sound effects on the first play, but it probably won't be very noticable if there's no latency on the preloaded gun/explosion/etc.

    It's very noticeable; it often takes ~2 seconds for a sound to play for the first time (if it plays at all) and it does not reflect well on your game. I've tried pre-loading all sounds but it doesn't really help. Do you have to pre-load sounds for each layout or just once at the opening layout?

  • Tokinsom

    An easy way is to add a condition in audio plugin to notice that the track is playable.

  • Just tried pre-loading all the sounds per level, which did the trick! I thought you just had to pre-load them once. Is there any drawback to pre-loading all the sounds/music at the same time? I didn't notice any pauses or anything at the start of the layout so..

  • For music, I remember Ashley told me a while ago not to pre-load it, just stream it. I was having a problem where the music would not play, and then I did what Ashley told me and just streamed it.

    I cannot talk for SFX though, as I did not play with those yet.

  • You shouldn't really pre-load music because it will stream from the server as it plays anyway, saving bandwidth and allowing the pre-load bandwidth to be used for SFX only. It shouldn't matter if music starts a second or two later.

    The Audio object has a global cache for all sounds in all layouts, so I don't know why preloading per-layout would change that at all. Really all you ought to do is set up some pre-loading for the latency-sensitive sounds (explosions, gun fire etc) on the very first layout of your game. Intros or title screens are good for this, e.g. if you flash up your logo for 5 seconds usually the browser can download all your latency sensitive sounds in the background during that, then everything will be ready when the game starts. If you pre-load on start of the game layout itself, and then start trying to play the sounds straight away, they still might not have finished downloading from the preloading, so there's not much point doing that.

    In other words, just preload a few things at the very beginning of the game, then try to have 5-10 seconds before the game itself starts, and everything should be ready.

    Note this only affects the first run - the second play will load from the disk cache so there will be no delays.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)