GameSalad

Howdy, Stranger!

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

Volume Slider?

iCliffiCliff Posts: 51Member
edited December 2011 in Working with GS (Mac)
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!

Comments

  • muoch10muoch10 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?
  • firemaplegamesfiremaplegames 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))
  • muoch10muoch10 Posts: 112Member
    thank firemaple, i always wondered if there was something wrong with the min and max expression.
  • ellfireellfire 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?
  • calvin9403calvin9403 Posts: 3,190Member
    Can you post your rule?

    Maybe you put min on the first, you should put max there
  • ellfireellfire 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))
  • calvin9403calvin9403 Posts: 3,190Member
    edited January 2012
    so you say it will go to the left?

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

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

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

    can you post a video record of it?
  • gyroscopegyroscope 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

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

  • ellfireellfire 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.
  • gyroscopegyroscope 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

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

    http://forums.gamesalad.com/discussion/38132/gs-tool-box-a-free-mega-template-ready-now/p1

    Theres also a video on page 2 showing you how to create a slider from scratch
  • ellfireellfire 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.

    Thanks to everyone for offering your advice and templates.
  • ellfireellfire Posts: 187Member
    edited January 2012
    Okay, new question: Does anyone know how to limit the volume slider. Ex. Now it correlates from zero to 1. Is there any way to correlate it so that the music maxes out at .7 say so that the default volume is .35?
  • pixlepixpixlepix Posts: 12Member
    Dont know your slider, but wouldnt multiplying the volume by .7 work?
  • ellfireellfire Posts: 187Member
    Hmmm. Perhaps. What I ended up doing was taking all my various tracks and arranging a pseudo game session in a multitrack sound editor, found good mix levels, then reexported my sound at those levels. This way, at least, all sounds are relative to each other in a way that I think is a good mix. What they do with it with the Vol and SFX sliders, if up to them.
This discussion has been closed.