相关疑难解决方法(0)

在Javascript性能上播放声音很重吗?

我在Javascript中制作一个简单的游戏,当一个物体与墙碰撞时,它会发出"砰"的声音.声音的响度取决于物体的速度(更高的速度=>更响的声音).

播放功能:

playSound = function(id, vol) //ID of the sound in the sounds array, volume/loudness of the sound
{
    if (vol) //sometimes, I just want to play the sound without worrying about volume
        sounds[id].volume = vol;
    else
        sounds[id].volume = 1;

    sounds[id].play();
}
Run Code Online (Sandbox Code Playgroud)

我怎么称呼它:

playSound(2, Math.sqrt(p.vx*p.vx + p.vy*p.vy)/self.TV); //self.TV stands for terminal velocity. This calculates the actual speed using the basic Pythagora's theorem and then divides it by self.TV, which results in a number from 0 to self.TV. 2 is the …
Run Code Online (Sandbox Code Playgroud)

javascript audio performance html5 html5-audio

2
推荐指数
1
解决办法
1340
查看次数

标签 统计

audio ×1

html5 ×1

html5-audio ×1

javascript ×1

performance ×1