High CPU / Crash under IOS Safari using p5 Audio js

Hey ive using the Audio lib for my shooter game but at several times the sounds crashes my game (on mac and iphone) seems the sound is the Problem if i only load the shoot sound, the browser Crashes after a while.

i make this:

shoot = loadSound(‘assets/sound/shoot.mp3’);

function shoot() {
shoot.play();
}

function keyPressed(e) {
if (key === ’ ') {
shoot();
}
}

Hi,
welcome to the processing forum !

You have actually some errors in your code when using the keypressed function. It does not actually expect any parameters, and you get the key by either keyCode either value (only in keyPressed). Take a look there : reference | p5.js

1 Like