INNER CODE UNIT · TypeScript

AudioManager

EvanBacon/Expo-Crossy-Road · src/AudioManager.ts:7

class AudioManager {
  sounds = AudioFiles;

  audioFileMoveIndex = 0;

  playMoveSound = async () => {
    await this.playAsync(
      this.sounds.chicken.move[`${this.audioFileMoveIndex}`]
    );
    this.audioFileMoveIndex =
      (this.audioFileMoveIndex + 1) %
      Object.keys(this.sounds.chicken.move).length;
  };

  playPassiveCarSound = async () => {
    if (Math.floor(Math.random() * 2) === 0) {
      await this.playAsync(this.sounds.car.passive[`1`]);
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…