Simulate unbounded scrolling?

Get help using Construct 2

Post » Sat Feb 11, 2012 5:42 pm

I have a bit of a problem.
At the beginning of every level, I want to zoom out and show the whole level. This sometimes looks really strange without 'unbounded scrolling' enabled.
However, when the game is 'zoomed in', the scrolling needs to be bounded so that the player knows when they are near the edge.

Any help? Perhaps a way to simulate either unbounded or bounded scrolling?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sat Feb 11, 2012 6:48 pm

You can simulate Bounded scrolling with unbounded with this:

Scroll to X: Clamp(Sprite.X, WindowWidth/2, LayoutWidth-WindowWidth/2)
Scroll to Y: Clamp(Sprite.Y, WindowHeight/2, LayoutHeight-WindowHeight/2)
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Sat Feb 11, 2012 8:07 pm

Thanks, @R0J0hound.
Will I run into any problems with rotating layouts?sqiddster2012-02-11 20:08:12
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Feb 14, 2012 2:14 am

OK, how would I do this in addition to layer scaling? I scale my main layer during the game and I do not want the player to be able to see outside the layout. @R0J0hound?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Feb 14, 2012 3:26 am

1. When the layout is rotated it behaves that same as normal bounded scrolling.

2. Change the formulas like so:
set scroll x: Clamp(Sprite.X, WindowWidth/(2*LayoutScale), LayoutWidth-WindowWidth/(2*LayoutScale))
set scroll y: Clamp(Sprite.Y, WindowHeight/(2*LayoutScale), LayoutHeight-WindowHeight/(2*LayoutScale))

If just the layer is scaled replace LayoutScale with LayerScale(layer).R0J0hound2012-02-14 03:27:05
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Tue Feb 14, 2012 11:01 am

Many thanks, as always.
@Kyat I suppose this might be good for the FAQ ;)
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Wed Feb 15, 2012 12:40 am

@Rojohound, when scaling is implemented, Sometimes I get to places where the layout 'jumps' to an unbounded state as soon as it is rotated a fraction. Very strange.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Thu Feb 16, 2012 9:22 pm

Sorry, name incorrectly. @R0J0hound? ^
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Feb 17, 2012 8:07 pm

Is it the same effect if you use just c2's built in bounded scrolling? The formula just replicates that.
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Wed Feb 29, 2012 12:21 am

If my window is near the bounds of my layout, scaling my main layer down for a zoom out effect makes the white space outside the layout visible. This corrects itself once I scroll away; I can no longer get outside the bounds when scrolling back to the edges.
It this a bug, or do I need to use clamp, something else?
B
6
S
2
G
3
Posts: 8
Reputation: 2,185

Next

Return to How do I....?

Who is online

Users browsing this forum: alextro, h1k3, Unconnected and 0 guests