Stopping sound before time?

Non-platform specific questions.

Stopping sound before time?

Postby Diana Kennedy » Fri Jan 06, 2006 2:25 am

Hi to all,

Is there a way to stop sound playing before it is finished?

In my game, I have an activation event that makes a wild animal changing its path and animation (from normal walking to galopping away) when the player clicks on the "make hunter take aim" area. It also causes a hoofbeat sound start playing. The soundclip is just as long that it covers all the way of the animal to flee out out of the view. Works really cool!
But when the hunter shoots his arrow and takes the animal down...the hoofbeat continues. Is there a was to make the hoofbeat stop when the animal is killed?

Diana
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby Novice » Fri Jan 06, 2006 7:20 pm

I also just noticed that there is no stop sound function. So i repeat the question.
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby makslane » Fri Jan 06, 2006 7:31 pm

Use the stopSound function.
Look this thread:

http://game-editor.com/forum/viewtopic. ... =stopsound
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Diana Kennedy » Fri Jan 06, 2006 11:06 pm

makslane wrote:Use the stopSound function.
Look this thread:

http://game-editor.com/forum/viewtopic. ... =stopsound



Eww, it deals with variables and so on. Isn't there a step by step tutorial with a working example? Where do I create a variable? in global code or in the script editor of the given actor (The animal)? I tried to "add variable" in the animal actor, it asks me questions like "channel" and so on, I have no idea what that means. The sound file in question names horse-galopp.wav. The actor is tarpan. So ca I have a clue where to write in what?
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby makslane » Sat Jan 07, 2006 1:18 am

Each sound in the game are played in a channel.
The PlaySound function returns the channel used to play the sound.

So, you must use the returned channel to control the sound (stopSound, setVolume, setPan)

You can create the variable with the "Variables" button in the "Script Editor"
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Diana Kennedy » Sat Jan 07, 2006 2:11 pm

makslane wrote:Each sound in the game are played in a channel.
The PlaySound function returns the channel used to play the sound.

So, you must use the returned channel to control the sound (stopSound, setVolume, setPan)


And how do I know which channel? Sorry, I didn't get that... :( Again, isn't there a working tutorial somewhere?

You can create the variable with the "Variables" button in the "Script Editor"


again, in the global script editor or in the script editor of the actor?

This would be strong wish for next versions of GE: Simply ad a "stop sound" action in the action lists, because this variables / channel thing is way too difficult for newbies like me. :cry:
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby Game A Gogo » Sat Jan 07, 2006 6:05 pm

Diana Kennedy wrote:again, in the global script editor or in the script editor of the actor?


in the script editor, dont worry, you will get better soon, it took me 2 years befor I knew what was a Variable in GE, lol.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Diana Kennedy » Sat Jan 07, 2006 9:42 pm

Game a Gogo wrote:
Diana Kennedy wrote:again, in the global script editor or in the script editor of the actor?


in the script editor,



Game...please.... in the script editor of THE ACTOR or in the GLOBAL SCRIPT EDITOR? :cry:

dont worry, you will get better soon, it took me 2 years befor I knew what was a Variable in GE, lol.


Yeah, then it will take me probably two centuries.. :wink:
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby Joshua Worth » Sat Jan 07, 2006 10:04 pm

Game a Gogo wrote:in the script editor, dont worry, you will get better soon, it took me 2 years befor I knew what was a Variable in GE, lol.

Once you learn it in GE you know it in pretty much everythng.

If you know algebra you should know how to use variables...
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby Diana Kennedy » Sat Jan 07, 2006 11:17 pm

Joshua Worth wrote:
If you know algebra you should know how to use variables...


I guess so. Well, I do NOT know Algebra. I managed to sleep through those classes during entire high school and college. maybe if back then I knew that there once would be a GE, I would have tried to get a notion or two of that nasty stuff.

:oops:
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby Game A Gogo » Sun Jan 08, 2006 2:53 pm

its in the actor scrotp editor, i can tell you a short ting about Var...

Var=Variable

A variable is a number or text that can be change and stored, a Var is use to "save" the pehipherique* of a state, but only for the time that the ged\exe\dat is open.

(* if you dant know what that meens, i dont ether, it make me look more smarther :wink: *)
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Diana Kennedy » Wed Jan 11, 2006 6:17 am

Ehm...Does anybody have some further help for this problem? I am really stuck with that and controlling sounds is quite of vital in my actual project. I would greatly apreaciate...
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby twobob » Wed Jan 11, 2006 11:13 am

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.

In your script where you have placed your code to play the sound/music
i.e PlaySound2("data/Tock.wav", 1.000000, 1, 0.000000);
You place in front of this the global variable that you created.
For example:
firesound1 = PlaySound2("data/Tock.wav", 1.000000, 1, 0.000000);

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
twobob
 
Posts: 33
Joined: Sat Sep 10, 2005 10:29 am
Location: England
Score: 2 Give a positive score

Postby Diana Kennedy » Sat Jan 14, 2006 7:28 am

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.

Image
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby twobob » Sat Jan 14, 2006 10:11 am

In your script, are you using the variables/functions button at the bottom of the script editor to add the sound – this allows you to set the volume/loop/pan control, and you should also hear the sound playing when you choose the file in the pop up box. This will also place the correct path to your sound file automatically.

The numbers in the enclosed brackets in the script are the volume/loop/pan which you alter in the pop up box.

To view the script reference for functions and what they do, in game editor click on help then documentation, on the left of the page choose scripting, and at the bottom of this page click on script reference.
twobob
 
Posts: 33
Joined: Sat Sep 10, 2005 10:29 am
Location: England
Score: 2 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest