1 decade ago by BrownHorse
I have a class that creates the sound objects. Then I create an instance of the class in my main.
Here is the module that creates the sound objects:
And here is the beginning of my main:
I believe I am pre-loading the sounds since I can add a print statement to the end of 'init' in the 'note-sounds' module and it will print during the loading screen.
Here is the module that creates the sound objects:
ig.module( 'game.note-sounds' ) .defines(function(){ ig.NoteSounds = ig.Class.extend({ guitar: null, trumpet: null, xylo: null, piano: null, fileNames: [ '_a1.*','_a2.*','_a3.*','_a4.*','_as1.*','_as2.*','_as3.*','_as4.*', '_b1.*','_b2.*','_b3.*','_b4.*', '_c1.*','_c2.*', '_c3.*','_c4.*','_c5.*','_cs1.*','_cs2.*', '_cs3.*','_cs4.*', '_d1.*','_d2.*','_d3.*', '_d4.*','_ds1.*','_ds2.*','_ds3.*','_ds4.*', '_e1.*','_e2.*','_e3.*','_e4.*', '_f1.*','_f2.*','_f3.*','_f4.*','_fs1.*','_fs2.*','_fs3.*','_fs4.*', '_g1.*','_g2.*','_g3.*','_g4.*','_gs1.*','_gs2.*','_gs3.*','_gs4.*', ], init: function(){ this.guitar = this.createArray("guitar", "g"); this.trumpet = this.createArray("trumpet", "t"); this.xylo = this.createArray("xylophone", "x"); this.piano = this.createArray("piano", "p"); }, createArray: function(name, letter){ var array = []; var path = "media/sounds/" + name + "/" + letter; for(i = 0; i < this.fileNames.length; i++){ array[i] = new ig.Sound(path + this.fileNames[i]); } return array; }, }); });
And here is the beginning of my main:
ig.module( 'game.main' ) .requires( 'impact.game', 'impact.font', 'game.levels.wave1', 'game.levels.wave2', 'game.levels.wave3', 'game.note-sounds', 'game.song-handler' ) .defines(function(){ GameScreen = ig.Game.extend({ noteBank: new ig.NoteSounds(),
I believe I am pre-loading the sounds since I can add a print statement to the end of 'init' in the 'note-sounds' module and it will print during the loading screen.