1 decade ago by fulvio
I have the following entity within my game:
Essentially what it's doing is checking to see whether the entity has hit the floor and if it has it stops the sound file. The problem is that on iOS only (using iOSImpact) the sound file plays once and stops playing but on the second time it's spawned (I can confirm it's killed properly) doesn't play.
Also, to add even more quirkyness it sometimes plays but when it collides with the floor the sound plays repeatedly until the
I thought that
Thanks in advance, any help would be greatly appreciated.
EntityTest = EntityParticle.extend({ size: { x: 16, y: 16 }, friction: { x: 40, y: 80 }, vel: { x: 100, y: 50 }, bounceCounter: 0, sfxBounce: new ig.Sound('media/sounds/bounce.*'), animSheet: new ig.AnimationSheet('media/sprites/test.png', 16, 16), init: function(x, y, settings) { this.addAnim('idle', 7, [0]); this.parent(x, y, settings); }, handleMovementTrace: function(res) { this.parent(res); if (res.collision.x || res.collision.y) { this.bounceCounter++; this.sfxBounce.play(); if (this.bounceCounter > 0) { this.sfxBounce.stop(); } } }, update: function() { this.parent(); } });
Essentially what it's doing is checking to see whether the entity has hit the floor and if it has it stops the sound file. The problem is that on iOS only (using iOSImpact) the sound file plays once and stops playing but on the second time it's spawned (I can confirm it's killed properly) doesn't play.
Also, to add even more quirkyness it sometimes plays but when it collides with the floor the sound plays repeatedly until the
EntityParticle
kills it.I thought that
this.sfxBounce.stop();
would stop the sound file from playing indefinitely. What am I doing wrong or how could I improve the code to get the desired outcome or is this simply a bug within iOSImpact?Thanks in advance, any help would be greatly appreciated.