Sound effect for button in Mole Game help

Hi, I’m a beginner using MIT App Inventor. I’m currently making a simple game where you tap a mole that moves around and each time you hit it you get a point and i added a sound effect for each time you successfully tap the mole.
I was able to get the sound to play when hitting the moles, but my main problem with the sound effect for hitting a mole is if I tap a mole and it triggers the sound effect and if I then Immediately tap another mole while the sound effect triggered by the previous mole is still playing it won’t restart and overlap the previous sound effect triggered to signify that I clicked on another mole and instead it can only replay the sound effect after the previous sound effect audio has ended so if I’m tapping the moles faster than the audio can end there are many moles I hit that won’t make a sound effect. Kind of hard to explain but if someone understands and knows how to fix this on MIT app inventor please let me know. Thank you.

Welcome Bryan.

I believe there isn't any way to eliminate the conflict. Your ability to click Moles fasts exceeds the ability of your Android to respond.

You can try these ways to minimize the problem:

  • use a Sound component, not a Player component

  • experiment with MinimumInterval . The Block specifies the minimum interval required between calls to Play, in milliseconds. Once the sound starts playing, all further Play calls will be ignored until the interval has elapsed.

  • use very short sound files. Use a tool like Audacity to trim the sound file length.

  • How are you coding to elicit a sound effect? How you code can affect what happens.

Experiment and see if your game will behave better if not perfectly. :wink:

Keep in mind, App Inventor is not a game engine. It is single threaded and cannot do several things simultaneously.

2 Likes

Thank you very much for the response, this helped .

A post was merged into an existing topic: Animal sound game app