1 decade ago by sunnybubblegum
What is the best way to set up a repeating sound effect for the player's footsteps?
This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact
var isShooting = ig.input.state('shoot'); // Did start shooting? if( isShooting && !this.wasShooting ) { this.wasShooting = true; // Play the sound this.soundShoot.play(); // Ensure that the callback is installed if( !this.soundShoot.currentClip.iloop ) { this.soundShoot.currentClip.iloop = true; this.soundShoot.currentClip.addEventListener( 'ended', (function(){ this.currentTime = 0; this.play(); }).bind(this.soundShoot.currentClip), false ); } } // Did end shooting? else if( this.wasShooting && !isShooting ) { this.soundShoot.stop(); this.wasShooting = false; }