Call me a math moron but...
twinpix
Member Posts: 49
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!
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
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?
I hope this helps
~CTM
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
But who im i to talk although im good at math im not always as good appling it