Call me a math moron but...

twinpixtwinpix Member Posts: 49
edited November -1 in Working with GS (Mac)
I am trying to build a slider and I've gotten it to work using the demo by firemaplegames and adapting to this formula to constrain my slider's values to 50 through 300:

game.SliderValue = 50+(250*(floor(self.Position.X - self.leftLimit)/(self.rightLimit - self.leftLimit)))

When the slider is moved, the values are correct (50 on the far left and 300 to the far right). Good so far.

Now, I want to save the SliderValue to disk and load it back in every time the user gets to the slider scene. Trouble is, I can't figure out how to make the slider jump to the correct saved position when the scene loads. What do I need to change the slider.PositionX to when the scene loads?

I know this is probably a simple math equation but I'm stumped. Help!

Comments

  • VoidedSkyVoidedSky Member Posts: 1,095
    Above all of the behaviors, put Change attribute self.positionX to 50, or what-ever you need.
  • twinpixtwinpix Member Posts: 49
    Yeah, that part I understand. What I'm asking is how to convert the value of the slider ( a number that is between 50 and 300) back to the screen position (a number that is between self.leftLimit and self.rightLimit). I know this is simple math but middle school was a LONG time ago. :)
  • twinpixtwinpix Member Posts: 49
    It's an iPad. I'm looking to convert the slider value (between 50-300) into the X position of my slider (between 245-520).

    So, if the Slider Value is 120, for example, what's the equation to find out where the X position of the slider is on the screen? Does that make sense?
  • VoidedSkyVoidedSky Member Posts: 1,095
    Put the slider at the left most part of the slider area, then double click on the Instance, check the position of it, and that should be your offset. so you just add that to your value of 50 to 300.

    I hope this helps
    ~CTM
  • firemaplegamesfiremaplegames Member Posts: 3,211
    The formula that I use in my volume slider demo is:

    self.Position.X = self.leftLimit +( game.musicVolume *( self.rightLimit - self.leftLimit ))

    In my case, I have game.musicVolume going from 0.0 to 1.0
  • jstrahanjstrahan Member Posts: 498
    Ok u asked for it math moron
    But who im i to talk although im good at math im not always as good appling it
Sign In or Register to comment.