Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by fulvio

I have the following entity within my game:

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.

1 decade ago by fulvio

I figured this out by adding a boolean to the update() to check whether it had hit the floor yet and I made quite a few adjustments as well. If anyone is interested in the entire entity code let me know and I'll share it.
Page 1 of 1
« first « previous next › last »