Twobob, Thank again for your assistance. Unfortunately, it did not work. (I probably messed up). So here is what I did:
twobob wrote:For each sound file create a Global variable with the "Variables" button in the "Script Editor". Name it (i.e firesound1) and choose integer and global so that you can use this variable anywhere in your game script to stop the sound/music.
Done. I called it galopp1
In your script where you have placed your code to play the sound/music
It wasn't done with a script. I used the "activation event". (When player clicks on the filled regions, horse flees in galop, changing path and animation - and sound)
Okay, so now I removed the play sound action of this activation event and instead of that used "activation event"-> script editor->
- Code: Select all
galopp1 = PlaySound2("data/horse-galop.wav", 1.000000, 1, 0.000000);
(By the way, for what does the 1.00000 and so on stand for?)
Anyhow: It did not work. No sound is played now and even the other actions related to this activation event, changing path and animation do not work anymore. The scrtipt seems to have killed all actions on that particular activation event. (Altough that they are still in the list)
When you want to stop the sound, in the script editor of the actor that controls your game, place the following code:-
stopSound(firesound1);
This will now stop any sound/music playing
What is meant by "actor that controls your game"? I worked in the actor that received the events and had to play the sound. (the wild horse)
Here is a screenshot for better understanding. The filled wires are the "aiming points." aim1, aim2 ,aim3 and so on. When clickling on it, an arrow actor is cretated, the hunter changes animation, the horse runs away and the sound of galop should be played. when right ctrl is clicked, the arrow is shot (following its path) and if horse crosses that path: collision, horse falls down, gallop-sound should stop.
I tried out your advice on one aiming point. Curious - the sound works not anymore also on the other aiming-points, too. But there, I didn't change anything.