Endless side scrolling

Get help using Construct 2

Post » Sun Nov 17, 2013 10:13 am

When you moves camera in some strategy game, it stucks in the border of game map, but what if camera will move looped?

Like this:


Any ideas?Vladoss2013-11-17 10:14:46
B
39
S
16
G
6
Posts: 238
Reputation: 7,915

Post » Sun Nov 17, 2013 12:39 pm

If you've made an interface layer (i'll call it UI) with parallax/scaling set to 0, you can use that to get the right mouse coordinates, and then compare that against the Border size/thickness

Var: Border = 50
If Mouse.x("UI") is greater than ViewportRight("UI")-Border --> scroll right

If Mouse.x("UI") is less than ViewportLeft("UI")+Border --> Scroll left

and do the same for Top and Bottom


edit: ViewportLeft("UI") and ViewportTop("UI") should always be 0
so you can do this instead:
If Mouse.x("UI") is less than Border --> Scroll left


There are other expressions to use instead of ones i've mentioned above, such as: WindowWidth, Mouse.AbsoluteX and CanvasWidth.. but I would avoid these because they can give different results depending on browser/device settings.keepee2013-11-17 12:45:27
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Sun Nov 17, 2013 3:37 pm

I'm not asking how to make side scrolling, I want make map borderless. If you will scroll camera to the right and as soon as you will reach border it won't stop, map will just shown from begging. And same thing for every direction.
B
39
S
16
G
6
Posts: 238
Reputation: 7,915

Post » Sun Nov 17, 2013 7:40 pm

this is psuedo of course and you will need fine tune.

If(Camera.X > limit) camera.X = 0
If(camera.x < 0) camera.x = limit

do the same for Y
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,028


Return to How do I....?

Who is online

Users browsing this forum: MassimoF, Microbex, Yahoo [Bot] and 24 guests