Thanks a million for getting back to me Daniel – you guys are always really helpful. It wasn't the filenames – as I changed them and it made no difference. I eventually played around more with it. I found that Hypes built in play sound and stop sound function didn't work for me on Android (Samsung s22 fe – Samsung Internet 23.0.0.47 – it initially wouldn't work on chrome on this device either) – sounds wouldn't be stopped and 2 audio files were playing at once. I had tried stopping sound using a javascript function. All voice files had the same class, so I just stopped them all. This worked on desktop when the javascript function was called from my ‘move to next scene’ button. It wouldn't work on mobile, I still don't know why (I know this is probably something to do with the way I have the document set up – but I can't figure out what it may be…). ANYWAY – calling the javascript function on scene unload seems to work, to stop sound.
So anyway – sound problem is now fixed.
I have noticed another problem, however – only on android, again – where a function isn't being fully executed.
I’m not going to worry about it too much now, as it was a halloween game for schools, and school in Ireland are all on holiday now – but I’ll post the code of this function, just in case there is an issue which jumps out at experts. I know the function is triggered because the first console.log appears. The second console log, however, after the line "function freagra(event)" doesn't appear, so function doesn't go further than this.
console.log("the function has started :-)");
scor++;
var correctRectangles = [
"corcra1",
"corcra3",
"corcra6",
"corcra8",
"corcra10",
"corcra12"
];
//var tomhasSpan = hypeDocument.getElementById("tomhas");
//tomhasSpan.innerHTML=3-scor;
//hypeDocument.getElementById("tomhas1").innerHTML=5-scor;
// Function to check if the user clicked a correct rectangle and play the appropriate timeline
function freagra(event) {
// Get the ID of the clicked element
var clickedID = event.target.id;
console.log(clickedID);
if (correctRectangles.includes(clickedID)) {
// Play the "maith_thu" timeline
hypeDocument.startTimelineNamed("maith_thu", hypeDocument.kDirectionForward);
return;
console.log("maith thú");
}
else if (scor==5) {
// Play the "maith_thu" timeline
hypeDocument.startTimelineNamed("caill", hypeDocument.kDirectionForward);
var amline= hypeDocument.getElementById("triail");
amline.style.display="none";
var trup = hypeDocument.getElementById('mi_adh_caint');
trup.volume=0;
return;
}
else {
//scor++;
console.log("scor:", scor); // Log the value of scor
if (scor<5)
{
hypeDocument.startTimelineNamed("triail_aris", hypeDocument.kDirectionForward);
}
}
}
hypeDocument.getElementById("tomhas1").innerHTML=5-scor;
// Add a click event listener to all remaining rectangles
for (var i = 1; i <= 12; i++) {
var rectangle = document.getElementById("corcra" + i);
if (rectangle) {
rectangle.addEventListener("click", freagra);
}
}
(live game can be found at: NuachtAnois – the error can be found in mobile devices on the 8th scene. It happens constantly on my own phone. A colleague, however, was able to have the function executed once on his own android phone perfectly, before the problem creeped in on the second attempt at playing the game)
Again, if something really obvious jumps out at someone – it would be great to find out what it is, but if not, I’ll just store this away until next Halloween and try to figure it out then. Many thanks again Daniel.