Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: CMK2901 on Fri 18/08/2006 00:43:07

Title: Checking if a slider is NOT active (SOLVED)
Post by: CMK2901 on Fri 18/08/2006 00:43:07
Hi,

You've probably played games where, when adjusting a volume slider, it plays a sound to let you sample the volume it is at.  That's what I'd like to do.  So far, I've got it changing the sound volume and playing a looping sound as it does.  This works fine.  However, when the user stops adjusting the sound, I'd like the sound sample to fade out.  The only problem is, I can't find any script item that would let me now when the slider is not being changed or active.

Any ideas for doing this?

(Srry about the double post; my internet was lagging)
Title: Re: Checking if a slider is NOT active.
Post by: Gregjazz on Fri 18/08/2006 01:57:52
In my head... check if the mouse button is down and it's over the coordinates of the entire slider. Then play the sound.
Title: Re: Checking if a slider is NOT active.
Post by: R4L on Fri 18/08/2006 01:58:23
Why don't you have a play sound button instead? You could let the player set the sound volume by using the slider and then have a button that plays a sound. It would be easier and faster.
Title: Re: Checking if a slider is NOT active.
Post by: Gilbert on Fri 18/08/2006 02:18:46
Just an idea, you may keep track of the slider's Value property, and check if it's not been changed for a certain amount of loops you may consider it to be inactive.
Title: Re: Checking if a slider is NOT active.
Post by: Gregjazz on Fri 18/08/2006 03:17:08
Quote from: Rap4Life42o on Fri 18/08/2006 01:58:23
Why don't you have a play sound button instead? You could let the player set the sound volume by using the slider and then have a button that plays a sound. It would be easier and faster.

Easier and faster to script maybe, but less convenient for the player.

I think Gilbot's onto something, though...
Title: Re: Checking if a slider is NOT active.
Post by: R4L on Fri 18/08/2006 04:38:41
How would it be less convenient? The only way I could see it happening is triggering the sound repeating through a globalint. Then when the mouse is over the slider or ifÃ,  the GUI is on it would change globalint 1 for example to two, and in rep_execute you could have an if statement with play sound to loop the sound, and have another if statement saying if that gui is off, set globalint 1 to 1. It's sloppy, but it would work.

EDIT: I misread. You want the sound to play when the slider is being activated and is being changed, then to fade out the sound when the player clicks off. Damn I need to take my time.  :D
Title: Re: Checking if a slider is NOT active.
Post by: Gilbert on Fri 18/08/2006 06:43:59
I'd mucked up a simple crappy demo (http://www.2dadventure.com/ags/slideract0000.zip) (can be made into a module, but I'm too lazy to do that) to show how this can be done. (Requires AGS V2.72 to compile, if you're not using V2.72 yet I can make one for other versions easily.)
If the slider is considered "active" the label text is white, it would turn to red if it's considered "inactive", currently if the slider value hasn't been changed for 40 loops (1 second, I set this for you to see the effect easier, change it to any other value according to your need) it would become inactive.

Just read the global script for how to do it, only stuff is located at the top of the script (variable declarations), and within repeatedly_execute()
Title: Re: Checking if a slider is NOT active.
Post by: CMK2901 on Sat 19/08/2006 18:47:11
Thanks a lot, that worked perfectly!

The only change I made is, rather than checking if the slider changed in repeatedly_execute, I just did that in slider_changed...just to reduce some clutter in repeatedly execute.

But it works perfectly.  Thanks again!
Title: Re: Checking if a slider is NOT active (SOLVED)
Post by: Gilbert on Mon 21/08/2006 03:21:02
Yeah, right, you can check it anywhere, as long as the timer decrement code is executed continuously everything will be okay (I think internal AGS timer may be used to save some work also, I was just to lazy to look up on their funcitons.)