• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

finishing off a scrollable list

G

gibberingmouther

Guest
i have a scrollable list i'm trying to code for my rpg. right now the up and down scroll buttons work and i know how to get the mousewheel to work. what i haven't incorporated are scrolling with the mouse or by clicking the empty space above or below the scroll bar. the latter isn't too important but i would like to incorporate mouse scrolling.

here's a working scrollbar: http://gmc.yoyogames.com/index.php?showtopic=681943&hl=+scrolling++list#entry4919477

i took a completely different approach than the scroll bar above but that one has a working mouse scroll so there might be something that could be taken from it. here is the very messy draw event. between the for loop and the draw rectangle codes the basic mechanism of scrolling should be clear: http://paste.ofcode.org/YbzKBahmBp6jV6ZSjQbmen

so i'm just trying to get the mouse scrolling to work, if anybody could help me. been working on this for awhile and kind of hit a sticking point because i'm dumb :(
 
F

FroggestSpirit

Guest
What I've done in that situation is to create a variable for the scrollbar to let it know if it was clicked on, and a relative mouse movement. Basically:
When clicked: set a variable clicked to true, and set another variable as scrollbar position-mouse position.
When global mouse release: set click to false.
Then while the scrollbar is clicked, just set it to mouse position + the relative position set when it was clicked.
 
Top