Basic preloading advice

Can anyone give me a quick summary of the basic technique used to preload assets for a game (IOS)

I notice if I launch my game and start it immediately, the first time a sound is played, there is a noticeable delay. I therefore assume I should be doing some sort of preloading to ensure my sounds have finished loading before starting the game.

All my sounds so far are short event sounds and I load and play them as follows:

  
-- Collision Sound  
  
local collisionSoundID = media.newEventSound( "bbHit2.caf" )  
  
   
local playCollisionSound = function()  
 media.playEventSound( collisionSoundID )  
end  
  
-- Lose Game Sound  
  
local loseGameSoundID = media.newEventSound( "whoosh.caf" )  
   
local playLoseGameSound = function()  
 media.playEventSound( loseGameSoundID )  
end  
  

Any advice on preloading audio (and images too) much appreciated.

Thanks

Paul [import]uid: 7863 topic_id: 2897 reply_id: 302897[/import]

I do the same like you do. I experience the lag only in the simulator, but not on the device. [import]uid: 5712 topic_id: 2897 reply_id: 8481[/import]

Thanks Mike, yeah it does seem to be worse on the simulator - perhaps the iPhone loads the sound before the game starts. [import]uid: 7863 topic_id: 2897 reply_id: 8487[/import]

Carlos gave me some direction to go in before I made my preloader.

http://developer.anscamobile.com/forum/2010/10/04/preloading-images

The idea is to instantiate assets, wait for the screen to redraw (enterframe), then load the next item. I have a module that accepts an array, then an enterframe handler that loops through the items in the array. It loads images, short sounds, and finally an mp3.

A good way to load in the mp3 is to play ( playSound() ), then pause it ( pauseSound() ).

Mike [import]uid: 4454 topic_id: 2897 reply_id: 8490[/import]

Thanks oz - I like the sound of this. I would love to get my hands on your preloader module:) [import]uid: 7863 topic_id: 2897 reply_id: 8491[/import]