Page 1 of 1

How do I make scroll bar?

PostPosted: Sat Aug 30, 2014 5:15 pm
by Xenovia
How do i make a scrolling bar like this?



Re: How do I make scroll bar?

PostPosted: Wed Sep 03, 2014 7:29 pm
by ruskul
Create 2 objects: the actual bar and the area the bar sits in. These should be created in a layer with parallax set to 0 (so these objects won't scroll). The bar needs some instance variables as well (IsClicked)

Then add the following events:

If bar clicked ----- set bar.IsClicked to true

if mouse click released && if bar.IsClicked = true ------ bar.IsClicked = false

If bar.IsClicked = true ------ set bar position (self.x, mouse.y)

EveryTick --------- Scroll to position (scroll.x ,( bar.positionY * some scale factor))

Because you have the scroll bar in its own layer that does not scroll, it should remain in place regardless of scroll. Some scale factor, if set to 1, will scroll as far as you move the bar. I would set this to 2 or 3 depending on how far you need to scroll.