Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 02/21/26 19:15
Camera always moves upwards?
by clonman. 02/21/26 09:29
Zorro version 3.0 prerelease!
by TipmyPip. 02/20/26 13:22
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 6,962 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
toggle sound on/off with same... button how too? #70261
04/10/06 01:12
04/10/06 01:12
Joined: Nov 2005
Posts: 49
Massachusetts
T
TBone Offline OP
Newbie
TBone  Offline OP
Newbie
T

Joined: Nov 2005
Posts: 49
Massachusetts
Hi
is there a way to turn sound on or off in real time?
I tried
Code:

function MusicOnOff()
{
if(sound_vol>0)
{ sound_vol = 0;
}
else
{
sound_vol = 100;
}
}



but this doesn't work real time
there is a function snd_stopall(parameter #) but I can't turn the theme music or sound effects back on

any ideas or am I completely missing something?

Thanks for the help


"Supreme executive power derives from a mandate of the masses NOT some farcicle aquatic ceromony" Constitutional peasant skit "Monty Python and the Holy Grail"
Re: toggle sound on/off with same... button how too? [Re: TBone] #70262
04/10/06 08:49
04/10/06 08:49
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
I think you want a music pause/play function,
here is an example :

Code:

var mediaHandle;
var isPlaying = on;

panel crtlPanel
{
pos_x = 0;
pos_y = 0;
layer = 1;
button = 0,0,<pauseOn.bmp>,<pauseOff.bmp>,<pauseOn.bmp>,musicOnOff,null,null;
flags = visible;
}

function musicOnOff()
{
if (isPlaying == on)
{
isPlaying = off;
media_start(mediaHandle); // if you want to start it all over again,
} else { // change it to media_play
isPlaying = on;
media_pause(mediaHandle);
}
}

function main()
{
level_load(yourLevel);
wait(2);

mouse_mode = 1;
media_play("yourMusic.wav",null,1000); // adjust the vol. (1000)
mediaHandle = media_handle;

while(1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
wait(1);
}
}



Use your own bmp and media file off course.

Re: toggle sound on/off with same... button how too? [Re: vlau] #70263
04/10/06 13:50
04/10/06 13:50
Joined: Nov 2005
Posts: 49
Massachusetts
T
TBone Offline OP
Newbie
TBone  Offline OP
Newbie
T

Joined: Nov 2005
Posts: 49
Massachusetts
That's great thanks,
but how do I do this so the the person just hits a key?

could I try
Code:

function musicOnOff()
{
if (isPlaying == on)
{
isPlaying = off;
media_start(mediaHandle); // if you want to start it all over again,
}
else
{
// change it to media_play
isPlaying = on;
media_pause(mediaHandle);
}
}



ADDED: On_P musicOnOff;//

I don't need the panel in the window to do this just a key.
I'm using the snd_play/snd_stop key words and they don't work real time

I'll try what you gave me and the key functionality and let you know probably won't be for a couple of days though

thanks again for the response


"Supreme executive power derives from a mandate of the masses NOT some farcicle aquatic ceromony" Constitutional peasant skit "Monty Python and the Holy Grail"
Re: toggle sound on/off with same... button how too? [Re: TBone] #70264
04/10/06 14:09
04/10/06 14:09
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Quote:


I don't need the panel in the window to do this just a key.
I'm using the snd_play/snd_stop key words and they don't work real time





snd_play function series don't have "snd_pause" unless you don't
need sound pause.

The advantage of media_play series is that you don't need to declare
the sound file previously and I think its more reliable.

If you want to toggle music on/off with a single key you may add

on_p = musicOnOff;

in your script.

Quote:


I'll try what you gave me and the key functionality and let you know probably won't be for a couple of days though





I'm sure you can make it perfectly.

Re: toggle sound on/off with same... button how too? [Re: vlau] #70265
04/10/06 20:16
04/10/06 20:16
Joined: Nov 2005
Posts: 49
Massachusetts
T
TBone Offline OP
Newbie
TBone  Offline OP
Newbie
T

Joined: Nov 2005
Posts: 49
Massachusetts
Hi
I'm sorry I'll try to be clearer in what I'm looking for.

explanation: I'm looking for a way to turn on and off the music and sound effects in my levels from the key board. I tried using sound_vol and setting it to 0 with a key command but this doesn't occur real time.

I did see some audio tutorials that incorporate some sort of CD player control via panels, similar or exactly what you were describing in your first response. I didn't see it until now.

I will try using the media_play series and let you know how it worked out

Thanks again


"Supreme executive power derives from a mandate of the masses NOT some farcicle aquatic ceromony" Constitutional peasant skit "Monty Python and the Holy Grail"
Re: toggle sound on/off with same... button how too? [Re: TBone] #70266
04/14/06 15:06
04/14/06 15:06
Joined: Nov 2005
Posts: 49
Massachusetts
T
TBone Offline OP
Newbie
TBone  Offline OP
Newbie
T

Joined: Nov 2005
Posts: 49
Massachusetts
Hi I converted all the media to mid and I'm using sound effects from wav files.
the following code turns off the Music, but not the sound effects, which turns out to be what I was looking for. You can only do this with midi_vol. snd_vol does not update real time. F12 does the same thing but I had to press it twice for it to work.

thanks for your help, here is the code I used
Code:

function Music()
{
if(isPlaying == on)
{
isPlaying = off;
midi_vol = 0;
}
else
{
midi_vol = 50;
isPlaying = on;
}

}
on_M Music;




"Supreme executive power derives from a mandate of the masses NOT some farcicle aquatic ceromony" Constitutional peasant skit "Monty Python and the Holy Grail"

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1