How do I make scroll bar?

Just started using Construct 2? Post your questions here

Post » Sat Aug 30, 2014 5:15 pm

How do i make a scrolling bar like this?

Image

Thanks!
B
18
S
2
G
1
Posts: 67
Reputation: 1,339

Post » Wed Sep 03, 2014 7:29 pm

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.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests