I have a problem I cannot solve
I have this slider class:
https://wiki.gideros.rocks/index.php/UI_Slider#Slider_with_IncrementsHow can I move the slider incrementaly? for example move the slider every value of 10?
Could you point me to a possible solution please?Thank you in advance
PS: you can copy/paste the class and it should be working out of the box + example provided as well.
This is for the paramaters for my game, or I might use imgui instead but I don't want to increase my app size too much
Comments
posX = self.width * value / self.maximum
e.g. something like:
posX = math.round(self.width * value / self.maximum /rounding_const)*rounding_const
i think that could be enough.
Likes: MoKaLux
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Therefore, you can add processing so that when the onMouseUp event occurs, the nearest integer is determined and the slider is set to it.
You can also develop to more accurately set the value (if necessary):
- when you left-click on the scroll bar, if the slider is to the right of the cursor, then it moves to the left by the step value and vice versa;
- or add buttons to the left and right (arrows or plus-minus), by clicking on which you add or remove a step value.
This will make it easier for the user to set a specific value.
And since the component is cool and moves smoothly, it's a pity that you can't set a step.
Likes: MoKaLux
Likes: E1e5en
http://forum.giderosmobile.com/discussion/886/simple-options-screen#Item_8
Likes: E1e5en, MoKaLux
Fragmenter - animated loop machine and IKONOMIKON - the memory game
https://wiki.gideros.rocks/index.php/UI_Slider#Slider_with_Increments
thank you keszegh, I will have a look at it EDIT: I prefer mine
Plus, you can leave the smooth movement of the slider when moving. And in the UP event, already shift to the nearest value.
you can set the maximum value and the steps (I just chose bad values in the example )
The only issue is how I handle the steps but you can change it to your needs.
https://wiki.gideros.rocks/index.php/UI_Slider#Slider_with_Increments
there is a little offset when you drag the slider
good enough for me though, thanks everyone for your help much appreciated
Viva gideros!
Likes: E1e5en
updated: https://wiki.gideros.rocks/index.php/UI_Slider#Slider_with_Increments
edit: you can easily add textures to the pixels
Peace.
Likes: E1e5en
True, we need to refine it a little more, but this is just as an experiment.
It was enough to add one line:
Likes: MoKaLux
Likes: E1e5en
(at)E1e5en can you try to improve it so it behaves as it should (with your modifications in previous posts) please? You can post your code here
Likes: E1e5en
Here is the code for the 3 events:
I believe that the code needs to be refined and slightly cleaned up, since the calculation of movement "in steps" during movement must be removed and all the functions and variables necessary for it.
When turning, it does not work very correctly, tk. just click elsewhere (not exactly hitting the component) and it will process.
Update:
Now it turns out that there are 2 versions of the development of this component:
- smooth movement and fixation on the value;
- switching when moving in steps.
And you need to develop in one direction.
Likes: MoKaLux
I need to review my code then. Thank you ;-)
Likes: E1e5en
Ps: i will also check the rotation issue.
Likes: E1e5en
only horizontal and vertical are working ok.
https://wiki.gideros.rocks/index.php/UI_Slider#Slider_with_Text_.28Increments.29
I think gideros imgui is the best option, but I wanted to try a quick slider
Peace and viva gideros
PS: please notice this line
if self.slit:hitTestPoint(event.x, event.y) or self.knob:hitTestPoint(event.x, event.y) then
PS2: particle effect by hgy29 https://wiki.gideros.rocks/index.php/Examples#PARTICLES_EFFECT_1_.40hgy29
EDIT: I added an id value in case of several sliders. Final?
Likes: E1e5en
https://wiki.gideros.rocks/index.php/UI_Slider#Slider_with_Text_.28Increments.29
END
Likes: E1e5en