How do I create a scrolling background?

Get help using Construct 2

Post » Mon Mar 26, 2012 9:23 pm

When I say a scrolling background, not something that scrolls when the player moves in that direction, but a background that scrolls by itself like in a title screen or something.
B
5
Posts: 13
Reputation: 401

Post » Mon Mar 26, 2012 9:42 pm

On start of layout: set instance variable originalX to background.X
On start of layout: set instance variable originalY to background.Y

Every tick: Background: move at angle self.angle

Compare two values:
distance(background.x,background.y,
background.originalX,background.originalY) >= tilewidth
-->
background: set position to self.originalX,self originalY.

This will let you scroll at any angle you want to tilt the background, and also take care of the tile discontinuity. It is assumed you will used a tiledbackground object. 'tilewidth' is the width of the source image, so it can loop back on itself seamlessly.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Mar 26, 2012 10:30 pm

[QUOTE=sqiddster]
Compare two values:
distance(background.x,background.y,
background.originalX,background.originalY) >= tilewidth
-->
background: set position to self.originalX,self originalY.
[/QUOTE]
Excuse my lack of substantial programming knowledge, but what's tilewidth?
B
5
Posts: 13
Reputation: 401

Post » Tue Mar 27, 2012 11:41 pm

I don't mean to be rude, but I still don't know what tilewidth is.
B
5
Posts: 13
Reputation: 401

Post » Tue Mar 27, 2012 11:50 pm

@Aero
'tilewidth' is the width of the source image, so it can loop back on itself seamlessly.'

He wrote it in his post... Last sentence.eyeliner2012-03-27 23:50:43
B
25
S
8
G
7
Posts: 184
Reputation: 6,040

Post » Wed Mar 28, 2012 12:07 am

Also you can find capx examples in the how do I FAQ section "Scrolling/Camera"
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Wed Mar 28, 2012 1:20 am

And now I'm stupid.

I misread that as "'tilewidth' allows you to have the source image, so it can loop back on itself seamlessly."

I should've reread it when it didn't make sense to me. I'm sorry.
B
5
Posts: 13
Reputation: 401

Post » Wed Mar 28, 2012 1:48 am

And it's not working.

I'm not sure what I'm doing wrong; I followed all the steps.

Here's my CAPX. Could someone please look at this and see what the problem is?

http://dl.dropbox.com/u/64495006/Solar%20Power%20v0.6.capxAero2012-03-28 01:49:06
B
5
Posts: 13
Reputation: 401

Post » Wed Mar 28, 2012 2:17 am

http://dl.dropbox.com/u/41931267/Snowfield.capx

Sorry, it's hard to keep track of all these topics, I wish there was a way to subscribe/unsubscribe to a topic!

Anyway, that should do it. You almost had it. I neglected to mention that the tiledbackground needs to be at least twice as wide as the screen. Really sweet title screen by the way!
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Wed Mar 28, 2012 10:41 pm

[QUOTE=sqiddster] http://dl.dropbox.com/u/41931267/Snowfield.capx

Sorry, it's hard to keep track of all these topics, I wish there was a way to subscribe/unsubscribe to a topic!

Anyway, that should do it. You almost had it. I neglected to mention that the tiledbackground needs to be at least twice as wide as the screen. Really sweet title screen by the way![/QUOTE]
Oh, thanks!

Thanks for the compliment, squiddster! I'm trying to make it look as cool as possible.

EDIT: Actually, you wouldn't happen to know if I can make it scroll but still follow along with the player?

I don't know if you get what I'm trying to say, but if I enlarge the scrolling tiled background to, say, a bigger layout, then it will just continually tile on and on when I go up or down, and I'm trying to make it, well, not do that and not scroll to the player.

Do you get it...? Sorry, I'm bad at explaining things. =P Aero2012-03-28 22:41:35
B
5
Posts: 13
Reputation: 401

Next

Return to How do I....?

Who is online

Users browsing this forum: alextro and 0 guests