#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Volume Slider?

Posts: 51Member
edited December 2011
I'm trying to create "volume sliders" for my game, but don't know how! Anyone know how to accomplish something like this in GameSalad?

Thanks!

• Posts: 112Member
I have a question with sliders, wouldn't it make more sense to use max and min expression in the constrain position x to mouse position x, instead of accomplishing the same result by doing two different constrain attributes, one to make a max and one to make a min, it seems that one constrain attributes is better then two right?
• Posts: 3,206Member
edited December 2011
Yes, I would use this formula if I were to make it again:

Constrain Attribute: self.Position.X To: max(self.leftLimit,min(self.rightLimit, Mouse.Position.X))
• Posts: 112Member
thank firemaple, i always wondered if there was something wrong with the min and max expression.
• Posts: 187Member
Hmmm. I tried using fire maple's formula (from TSBooth's video tutorial), and, for some reason, as soon as I click my slider it doesn't constrain to the touch, but pop and locks into place at the min location. Any ideas what could cause that?
• Posts: 3,190Member

Maybe you put min on the first, you should put max there
• Posts: 187Member
In my slider, I have two Attributes set: Slider_Min to 1298, and Slider_Max to 1776. These are both X coordinates on a double wide scene. (Ie. This is screen two so it starts at 1024 to 2048 in X)

My rule is:
When actor receives event touch is pressed:
Constrain Attribute self.PositionX to max(self.Slider_Min,min(self.Slider_Max,game.Mouse.Position.X))
• Posts: 3,190Member
edited January 2012
so you say it will go to the left?

• Posts: 8,980Member, Sous Chef, PRO, Bowlboy Sidekick
edited January 2012
Edit: My apologies - I didn't see that @ellfire said he built this slider from Tshirtbooth's video.

Bray
• Posts: 187Member
edited January 2012
If I remove "Touch is pressed" how will it receive input?

No worries, Braydon
• Posts: 3,190Member
on your device you won't I guess

can you post a video record of it?
• Posts: 187Member
• I am here.Posts: 6,577Member, Sous Chef, PRO
edited January 2012
Hi ellfire, a possibility of solving your prob: take a look at the Rule under the Note "If you drag the slider past its left limit, constrain the X position to the left limit." and make sure, where it should say game.Mouse.Position.x is less than or equal to self.leftLimit, you haven't put more than or equal to.

----------------------------------------------
http://davidgriffinapps.co.uk/

""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

• Posts: 3,190Member
can't tell why you have the problem

• Posts: 187Member
edited January 2012
Sorry, Gyro, I'm not sure where your getting and less than or equal to rule? Did I miss a step? I only used TSB's video, not the template linked above.
• I am here.Posts: 6,577Member, Sous Chef, PRO
edited January 2012
Oh right, I thought you used FMG's template.... I'll take a look tomorrow to see if I can find anything but as previously said, hopefully another member will come to your rescue in the meantime.... fingers crossed.

Edit: hang on, TSB's link IS for FMG's template... I'm confused again...

Edit again: maybe try replacing your line with the one supplied by FMG; just a thought...

""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

• Posts: 187Member
Yep, somehow, I just keep finding these almost inexplicable oddities.
• Posts: 5,390Member
There is a free template here which has a volume slider in;

Theres also a video on page 2 showing you how to create a slider from scratch
• Posts: 187Member
Okay, so the mystery has been solved. My rule was just like TSB's in his video. What I wasn't accounting for was this: The scene in which the slider exists is 3072 wide by 1536 high. In it are 4 menus in a "T" configuration. I start out at the center top of the "T" then pan left, right, or down to show the other menu by interpolating the Camera Origin. The menus with the slider takes place at the bottom of the "T" between 1024 and 2048 in X. So, my Min and Max values for my slider were correct, but I had to add 1024 to the mouse/touch position to account for the fact this menu existed between 1024 and 2048 in X. Hope that makes sense to folks.