Good day,
like I said earlier, I am not really familiar with the audio api, so I cannot really tweak your method. So this is what I came up with.
Since everytime a card is clicked, we get the dataset-id and then use this to get the name from the array, you can easily play the sound from there
let clicked =cardArray[selected].name
cardsSelected.push(clicked);
source.src=${clicked}.mp3
audio.load()
audio.play()
I also updated it in the link.
But for your method, you can try
let clicked =cardArray[selected].name
cardsSelected.push(clicked);
let sound =new Audio(./${clicked}.mp3)
function playSound(sound){
sound.play()
}
playSound(sound).
This will be called each time a card is clicked, you can just simply interchange it with the one above. I commented this out in the codepen link.
Good day,
like I said earlier, I am not really familiar with the audio api, so I cannot really tweak your method. So this is what I came up with.
Since everytime a card is clicked, we get the dataset-id and then use this to get the name from the array, you can easily play the sound from there
let clicked =cardArray[selected].name
cardsSelected.push(clicked);
source.src=
${clicked}.mp3
audio.load()
audio.play()
I also updated it in the link.
But for your method, you can try
let clicked =cardArray[selected].name
cardsSelected.push(clicked);
let sound =new Audio(
./${clicked}.mp3
)function playSound(sound){
sound.play()
}
playSound(sound).
This will be called each time a card is clicked, you can just simply interchange it with the one above. I commented this out in the codepen link.
hello bro ;) I did it
check my game out here:
english-quiz.cba.pl/Memory%20game/...
thanks for all your help
Whoa, I love this.
Well done :) :)
hello sir can you please help me i added audio in my game but 'm facing some issue with the audio