yasdar Posted June 19, 2015 Share Posted June 19, 2015 Hello,I have a game that uses many sounds , i don't want to load all sounds at the start of the game this will make this will make the player waiting for 5 min .I need to load one sound and play it when player click a button. i did this ://when player click a button this.game.load.audio("apple", ["assets/sounds/apple.mp3"]); var _sound= this.game.add.audio("apple");_sound.play('',0,1,false) but the console say :Phaser.Cache.getSound: Invalid key: "apple" any solution ?Thank you. Link to comment Share on other sites More sharing options...
drhayes Posted June 19, 2015 Share Posted June 19, 2015 The sounds has not loaded yet by the time you're trying to add the audio. If you split your game into multiple states each state can have a preload function that loads assets that you use for that state. Link to comment Share on other sites More sharing options...
yasdar Posted June 20, 2015 Author Share Posted June 20, 2015 Thank you for help drhayes.this is a good solution Link to comment Share on other sites More sharing options...
Recommended Posts