Page 1 of 6

How scroll bar??

PostPosted: Mon Apr 09, 2007 5:31 pm
by Troodon
Hi,
I haven't found out yet, how you guys make those scroll bars which affect to variables? I've tried different things, but nothing seems to work. :/
And how you limit their moving in a small area?

PostPosted: Mon Apr 09, 2007 6:41 pm
by Sgt. Sparky
1. what is the range of the variable you want?
2. what is the limit x, and y, you want the actor to move in?
3. is it a verticle scrolling bar, or is it a horizontal scrolling bar?
4. does it move with a window you can drag?
:D
yes, you can do that.
please answer my questions and I can tell you what to do. :)

PostPosted: Wed Apr 11, 2007 2:12 pm
by Troodon
Thanks Sparky :D
1.The range is from a to b (for example 0-100)
2.From x1 to x2 or from y1 to y2
3.I'd need both vertical and horizontal
4.I drag an actor with mouse

PostPosted: Thu Apr 12, 2007 12:02 am
by Sgt. Sparky
for the mouse button down event drag enabled,
Code: Select all
y = yprevious;//or y = what you want it to be.
if(x < 0)x = 0;
if(x > 100)x = 100;
myVar = x *2.5;

that is for the horizontal version,
here is verticle,
Code: Select all
x = xprevious;//or x = what you want it to be.
if(y < -100)y = -100;
if(y > 0)y = 0;
myVar = -y *2.5;

:)
I hope that helps!
:D

PostPosted: Sat Apr 14, 2007 10:36 am
by Troodon
Wait,
I made like this:
y = yprevious;
if(x < 0)x = 0;
if(x > 100)x = 100;
kuva.r = x *1;


and it's quite buggy. Maybe you could give that code with example numbers.
For example my button actor should move only vertically and in the one specified area. Then it should change for example the classic colour variable 'r' so that max left is 0 and max right is 255.

PostPosted: Sat Apr 14, 2007 6:13 pm
by Sgt. Sparky
erm, that code is wrong for the horizontal thingie I gave you. :(
use this for verticle of a moving range of 0 to 255, and a variable range from 0 to 255:
Code: Select all
xscreen = what-you-want-it-to-be;
if(yscreen < 25)yscreen = 25;
if(yscreen > 280)yscreen = 280;
kruva.r = yscreen - 25;

use this for a verticle moving range of 0 to 100, and a variable range from 0 to 255:
Code: Select all
xscreen = what-you-want-it-to-be;
if(yscreen < 25)yscreen = 25;
if(yscreen > 280)yscreen = 280;
kruva.r = (yscreen*2.5) - 25;

:D
I hope that helps,
here is a version of it where you can change one variable on the create actor event to a different number to change location without modifying your code, first you must make a variable called MIN_YSCREEN and one called XSCR_POS, then use this here,
draw actor event:
Code: Select all
xscreen = XSCR_POS;
if(yscreen < MIN_YSCREEN)yscreen = MIN_YSCREEN;
if(yscreen > MIN_YSCREEN + 100)yscreen = MIN_YSCREEN + 100;
kruva.r = (yscreen*2.5) - MIN_YSCREEN;

and here is for create actor event:
Code: Select all
XSCR_POS = what-you-want-it-to-be;
MIN_YSCREEN = what-you-want-the-minimum-yscreen-limit-to-be;

:D
I hope that helps. :)
EDIT: you said max left and max right
and you also said verticle...?
so I just gave you the verticle code,
you can change it around to make it horizontal. :)

PostPosted: Sat Apr 14, 2007 7:05 pm
by Troodon
I can't make it work like it should. Maybe there is something I don't understand in english. Btw in my last post I messed vertical and horizontal. :oops:
My scroll bar should be horizontal. However, when you have time, can you make me one example ged file? Thanks.

PostPosted: Sun Apr 15, 2007 7:24 pm
by Sgt. Sparky
just send me yours, I am workin' on ANSI C compiling right now with another program(I am still going to use GE do not worry!)
but I will be able to find time :)

PostPosted: Sun Apr 15, 2007 7:35 pm
by Troodon
Thanks, I will send you my file as soon as I get to my computer. 8)

PostPosted: Mon Apr 16, 2007 1:46 pm
by Troodon
Sparky, I am on my computer and here is my scroll bar example.

PostPosted: Tue Apr 17, 2007 1:34 am
by Sgt. Sparky
I will open it up in just a few mins(busy) :)

PostPosted: Tue Apr 17, 2007 4:32 pm
by Troodon
Ok, no problem. :D

PostPosted: Tue Apr 17, 2007 5:52 pm
by Sgt. Sparky
Code: Select all
y = palkki.y - height / 2;
population = (x + 100) * 5;
if(x < -100)x = -100;
if(x > 100)x = 100;

put that in the draw actor event of nappi.
on the mouse button down event with drag enables just use
Code: Select all
;

:D
you may need to change the pakki animation,
I started it with using width and stuff and x positions but it did not work.
the number I had to use to calculate it was: 3.086419753... ect.
infinitely repeating the 086419753 again and again.
try making the pakki animation 215x25 instead of 325x125
:D

PostPosted: Fri Apr 20, 2007 3:33 am
by Troodon
Thanks, I'll try that right now! :D

By the way, I forgot to mention that the pakki animation is made with tiles, so you could have changed it if you wanted. :wink:

PostPosted: Fri Apr 20, 2007 3:36 am
by Sgt. Sparky
xD
okay