Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / [SOLVED] Sliders

Author
Message
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 11th May 2019 17:51
Hello Forum,

I want to create a slider out of sprites and when I am moving it, I want a variable to increase or decrease depending on the slider's knob position. I tried myself to do it but I got stuck... Here is my attempt:



Huge thanks!
www.alexmatei.com

The author of this post has marked a post as an answer.

Go to answer

chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 11th May 2019 22:37
Hi mate . It looks ok to me ..... take a look to this piece of code






Cheers.
I'm not a grumpy grandpa
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 12th May 2019 11:08
Chafari,

Good to see you again! Really! Last time we interacted on the forums, was in the DarkBasic Professional era. Haha!

Regarding the code, this is exactly what I wanted. I have one question about it. Is it possible to create an independent variable to modify with the sliders and start it's increment from it's own independent starting point, not based on the starting point of the sprite slider? I mean, I think this would help to position the sliders wherever we want without altering the final result of the variable.

Thank you so much and again, nice to see you again!
www.alexmatei.com
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th May 2019 17:36 Edited at: 12th May 2019 17:49
Hi mate . Nice to know you are still around the forum .

I have done something like that long ago....you have to do something like a herarchy to reference the x,y of the main Sprite and the rest of sprites will be childs of the main one . Something like this :




I hope that can help ....I've got my code like a mess in a Dbpro script .Sorry.

Cheers.
I'm not a grumpy grandpa
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 19th May 2019 10:24
I followed your example, Chafari and this is what I came up with:
Sorry for the late response:



Based on this code, how can I make to drag the knob without going left or right on the bar?

Thank you so much for your help!
www.alexmatei.com
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th May 2019 12:05
Quote: "how can I make to drag the knob without going left or right on the bar?"


For that you could use your first code above ,and create the sprite for the mouse something wider .... then place the mousesprite in getpointerx () -15 , getpointery() . Finally, do not forget to hide the mouse sprite either by making it invisible or by adjusting its alpha color .
SetSpriteColorAlpha(1,0) or setspritevisible(1,0)

Here's your modified code .






I'm not a grumpy grandpa
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 19th May 2019 13:52
yes, but that eliminates the need for a separate variables, which, the separate variable is a must. In my code, "slider" was incrementing weirdly and it was not detecting when it was scrubbing on the left or on the right. If that makes sense
www.alexmatei.com
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th May 2019 14:01
I will post a new code when ready .I will do some more test .
I'm not a grumpy grandpa
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 19th May 2019 14:50
Absolutely awesome!

Thank you so much!
www.alexmatei.com
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th May 2019 18:08 Edited at: 19th May 2019 19:03
This post has been marked by the post author as the answer.
Here's what I have so far ... it needs some adjustments ... I'm doing something more elegant ....in the meanwhile take a look .




Little update.



I'm not a grumpy grandpa
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 23rd May 2019 14:19
Thank you for your help, Chafari!
www.alexmatei.com
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 23rd May 2019 16:59
You are welcome !
I'm not a grumpy grandpa

Login to post a reply

Server time is: 2024-04-25 04:39:02
Your offset time is: 2024-04-25 04:39:02