How do I limit scrolling on a layout?

Get help using Construct 2

Post » Fri Mar 17, 2017 12:44 pm

Let me explain my problem.

This is how my lookout looks like:
http://i.imgur.com/nIkYi91.png

- On start of layout the camera is scrolled to the middle of the black rectangle (1080x1920px).
- When double tapped you zoom in to an area (2x) and are able to move around. Double tap again to set zoom to 1x and scroll to the middle of the black rectangle again.

I've figured out the 2 things above. But I don't know how to limit zooming in and scrolling around to the black area only. I don't want the player to see the white area at all.

Anyone knows a good solution for this? :?
B
10
S
4
Posts: 34
Reputation: 874

Post » Fri Mar 17, 2017 7:57 pm

I've found a solution myself. I'm using the "Boundary" plugin by rex. Not 100% perfect but it works.
B
10
S
4
Posts: 34
Reputation: 874

Post » Sat Mar 18, 2017 2:39 am

@Turaco

I recently was working on doing something very similar - although I was also trying to use the entire screen (regardless of device size or orientation) by using Scale Outer and Unbounded scrolling (which added an extra level of complexity that took me an entire long weekend to work out).

it is just a matter of calculating how far the layout is allowed to scroll, and keeping within those limits.
So, here is how I would do what you were asking - no plugins required:

http://www.rieperts.com/games/forum/ScrollLimit.capx

this version does the double tap to zoom you mentioned, but I also included how I track multiple touch points, and do pinch to zoom... I also added a button to turn the limit feature on and off so that you can see that it really works.
B
97
S
34
G
20
Posts: 438
Reputation: 17,790

Post » Sat Mar 18, 2017 11:41 am

@AllanR Thanks a lot. Although I think I'll keep using the plugin because it's simpler (you just set boundaries to image points of an object -background picture). Also I noticed when I zoom in in your project I always get to the middle of the layout and not the point i clicked.

My problem is that my zooming in isn't instantaneous but over time. So when I zoom onto target location where my boundaries cut off, I get kinda shaky animation of zooming in.

Thanks for the effort tho.
B
10
S
4
Posts: 34
Reputation: 874

Post » Sat Mar 18, 2017 11:44 am

You could use scale rate
Image
B
25
S
14
G
12
Posts: 291
Reputation: 9,404

Post » Sat Aug 19, 2017 7:49 pm

What you want to do is make a global variable called GameScale (or whatever you want) and on the mousewheel up or mousewheel down condition dictated events that you create remember to make a system>compare two values gamescale > or < than so you can limit the zoom on these mousewheel events. Okay, now do a System> Every Tick event and then a System>Set Layer Scale set your layer to lerp(Layerscale(0), GameScale, 0.03) for layer 0 and if your more than one layer than system>set layer scale> to layerscale 0 for all other layers.

Tada a smooth camera!

My source for this information is the examples that come with Construct 2: RTS / Driving Game Template.
B
9
S
2
Posts: 24
Reputation: 573


Return to How do I....?

Who is online

Users browsing this forum: Bobbyneal100, Euduardo, Kin, mickclarke, mikehive, tinhofiel, TRMG, usochi and 43 guests