@@ -86,7 +86,7 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
8686 }
8787 this . _playingMusic = keyname ;
8888
89- if ( this . _effectList . hasOwnProperty ( keyname ) ) {
89+ if ( this . _muiscList . hasOwnProperty ( keyname ) ) {
9090 au = this . _muiscList [ keyname ] ;
9191 } else {
9292 au = new Howl ( {
@@ -214,24 +214,19 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
214214 this . _effectList [ keyname ] = au ;
215215 }
216216
217+ //to prevent a bug. when one effect plays in a loop,
218+ //no effect of the same type can play at the same time
219+ if ( au . loop ( ) ) {
220+ return keyname ;
221+ }
222+
217223 if ( loop ) {
218224 au . loop ( loop ) ;
219225 }
220226 au . play ( ) ;
221227 return keyname ;
222228 } ,
223229
224- /**
225- *The volume of the effects max value is 1.0,the min value is 0.0 .
226- * @return {Number }
227- * @example
228- * //example
229- * var effectVolume = cc.AudioEngine.getInstance().getEffectsVolume();
230- */
231- getEffectsVolume :function ( ) {
232- return this . _effectList [ 0 ] . volume ( ) ;
233- } ,
234-
235230 /**
236231 * Set the volume of sound effecs.
237232 * @param {Number } volume Volume must be in 0.0~1.0 .
@@ -250,8 +245,10 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
250245 this . _effectsVolume = volume ;
251246 }
252247
253- for ( var i = this . _effectList . length - 1 ; i >= 0 ; i -- ) {
254- this . _effectList [ i ] . volume ( volume ) ;
248+ for ( var key in this . _effectList ) {
249+ if ( this . _effectList . hasOwnProperty ( key ) ) {
250+ this . _effectList [ key ] . volume ( volume ) ;
251+ }
255252 }
256253 } ,
257254
@@ -265,7 +262,7 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
265262 pauseEffect :function ( path ) {
266263 var keyname = this . _getPathWithoutExt ( path ) ;
267264 if ( this . _effectList . hasOwnProperty ( keyname ) ) {
268- this . _effectList [ keyname ] . pause ( ) ;
265+ this . _effectList [ keyname ] . loop ( false ) . pause ( ) ;
269266 }
270267 } ,
271268
@@ -276,8 +273,10 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
276273 * cc.AudioEngine.getInstance().pauseAllEffects();
277274 */
278275 pauseAllEffects :function ( ) {
279- for ( var i = this . _effectList . length - 1 ; i >= 0 ; i -- ) {
280- this . _effectList [ i ] . pause ( ) ;
276+ for ( var key in this . _effectList ) {
277+ if ( this . _effectList . hasOwnProperty ( key ) ) {
278+ this . _effectList [ key ] . loop ( false ) . pause ( ) ;
279+ }
281280 }
282281 } ,
283282
@@ -302,8 +301,10 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
302301 * cc.AudioEngine.getInstance().resumeAllEffects();
303302 */
304303 resumeAllEffects :function ( ) {
305- for ( var i = this . _effectList . length - 1 ; i >= 0 ; i -- ) {
306- this . _effectList [ i ] . play ( ) ;
304+ for ( var key in this . _effectList ) {
305+ if ( this . _effectList . hasOwnProperty ( key ) ) {
306+ this . _effectList [ key ] . play ( ) ;
307+ }
307308 }
308309 } ,
309310
@@ -317,7 +318,7 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
317318 stopEffect :function ( path ) {
318319 var keyname = this . _getPathWithoutExt ( path ) ;
319320 if ( this . _effectList . hasOwnProperty ( keyname ) ) {
320- this . _effectList [ keyname ] . stop ( ) ;
321+ this . _effectList [ keyname ] . loop ( false ) . stop ( ) ;
321322 }
322323 } ,
323324
@@ -328,8 +329,10 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
328329 * cc.AudioEngine.getInstance().stopAllEffects();
329330 */
330331 stopAllEffects :function ( ) {
331- for ( var i = this . _effectList . length - 1 ; i >= 0 ; i -- ) {
332- this . _effectList [ i ] . stop ( ) ;
332+ for ( var key in this . _effectList ) {
333+ if ( this . _effectList . hasOwnProperty ( key ) ) {
334+ this . _effectList [ key ] . loop ( false ) . stop ( ) ;
335+ }
333336 }
334337 }
335338
0 commit comments