Infinitely scrolling background

For questions about using Classic.

Post » Wed Oct 07, 2009 3:19 pm

I'm going to be making a parallax background, but instead of extending the level by whatever amount I'm just going to have the backgrounds scroll and loop endlessly. I'm wondering if Construct has built-in support for this or if I'm left to my own inventions.

If you don't understand I'll try to explain it. Imagine a 200x100 image that connects on the right and left so that if you were to place them side-by-side they would look continuous. This is essentially the idea, but I'd rather not have to make the level huge and just have the image scroll through itself continually.
B
2
G
3
Posts: 68
Reputation: 986

Post » Wed Oct 07, 2009 3:25 pm

There is an effect named "offset". By changin the offset value in runtime you can make continuously scrolling image.
B
2
S
1
G
4
Posts: 71
Reputation: 1,342

Post » Wed Oct 07, 2009 4:07 pm

Sorry, could you give an example. I'm not understanding.

I currently have Every Tick: TiledBackground: Offset: Set Offset Y to 100 * TimeDelta. This does nothing.

I've also tried placing it in Start of Layout rather than Every Tick.
B
2
G
3
Posts: 68
Reputation: 986

Post » Wed Oct 07, 2009 5:29 pm

http://www.4shared.com/file/138306311/b ... round.html

you could do it like this, it uses two background/sprites set next to each other moving at the same x speed - at the end of the screen the first one sets it back to the beginning,

done it quickly, you could much improve it using vars, you could even use the same sprite i guess, with some picking event

but just shows the idea
B
2
G
3
Posts: 72
Reputation: 994

Post » Wed Oct 07, 2009 5:40 pm

It's much easier to do with offset: http://www.mediafire.com/?zyudkmnmz5m
B
2
S
1
G
4
Posts: 71
Reputation: 1,342

Post » Wed Oct 07, 2009 5:59 pm

but can you move the background while the player stays in position with this function?

edit: ow i misunderstood the question i think
B
2
G
3
Posts: 72
Reputation: 994

Post » Wed Oct 07, 2009 6:12 pm

I'm not sure I explained it properly. My layout will only be 1024x768 in size. I want the tiled background to, for example, scroll continuously at the sides regardless of whether the character is moving or not.

EDIT: Aphex, your example is what I'm actually looking for, I just didn't know if there was a more automated/efficient way of doing it or if I should just do it like that.
B
2
G
3
Posts: 68
Reputation: 986

Post » Wed Oct 07, 2009 6:18 pm

no the offset works

i just tested it by adding a global var 'counter'

and always add 1 to the counter en put that var in x offset
B
2
G
3
Posts: 72
Reputation: 994

Post » Wed Oct 07, 2009 6:21 pm

You can use a tiled background, set its X offset to whatever you want it to scroll like - if you want it to scroll with the character, set X offset to Character.X*factor (factor being scrolling speed, parallax). If you want it to scroll over time, set X offset to, umm, whatever that system expression for ticks is. To make sure it doesn't overflow, just substract it by tiled background image width whenever it goes over that number.

My mind is blank at the moment and still don't have Construct installed, so hopefully someone else can produce an example.

Or using the global counter works, too. Just remember to reset it to zero after the background is fully looped, otherwise it will overflow in the future.

Instead of adding 1, add 60*timedelta, 60 being scrolling speed you can adjust if you want. Smooth scrolling!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Wed Oct 07, 2009 6:25 pm

Ok, i misunderstood the question. Just do what Aphex said.
B
2
S
1
G
4
Posts: 71
Reputation: 1,342

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest