Volume Slider?

iCliffiCliff Member Posts: 51
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 Member Posts: 112
    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 Member Posts: 3,211
    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 Member Posts: 112
    thank firemaple, i always wondered if there was something wrong with the min and max expression.
  • ellfireellfire Member Posts: 187
    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 Member Posts: 3,186
    Can you post your rule?

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

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

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

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

    can you post a video record of it?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    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 Member Posts: 3,186
    can't tell why you have the problem

  • ellfireellfire Member Posts: 187
    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.Member, Sous Chef, PRO Posts: 6,598
    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 Member Posts: 187
    Yep, somehow, I just keep finding these almost inexplicable oddities.
  • beefy_clyrobeefy_clyro Member Posts: 5,394
    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 Member Posts: 187
    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 Member Posts: 187
    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 Member Posts: 12
    Dont know your slider, but wouldnt multiplying the volume by .7 work?
  • ellfireellfire Member Posts: 187
    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.
Sign In or Register to comment.