Possible to pinch-zoom canvas?

Get help using Construct 2

Post » Tue Aug 23, 2016 8:03 am

@oosyrag I modified the values properly. Now, it is working great. Thank you so much man.
B
24
S
7
Posts: 337
Reputation: 2,224

Post » Wed Aug 24, 2016 7:54 am

I'm banging my head on the wall trying to figure out how to keep the image from panning outside of the layout and adding some kind of smooth panning or inertia to it.

Is there a condition that checks the image's edge or bounding box and have it stop panning if the the image is at edge of the layout so it prevents it form infinitely scrolling out of bounds?

I can do this by placing a sprite and designating it as a camera with ScrollTo and BoundToLayout, but the example provided is referencing the actual layout instead of a sprite object.
B
14
S
6
G
5
Posts: 3
Reputation: 3,506

Post » Wed Aug 24, 2016 6:05 pm

Using an invisible helper sprite is perfectly acceptable and recommended for ease of use.

Otherwise, you may use the viewport expressions to get the edges of the screen and use those as a condition to keep the scroll event from running past the layout edges.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Thu Sep 01, 2016 8:50 pm

oosyrag wrote:Using an invisible helper sprite is perfectly acceptable and recommended for ease of use.

Otherwise, you may use the viewport expressions to get the edges of the screen and use those as a condition to keep the scroll event from running past the layout edges.


Haven't tried this yet, but combining this with clamp should keep the contents of the layer within bounds, correct or am I talking nonsense? Would this also take into consideration the current scale of the layout when zoomed in?

X : clamp( Self.X, ViewportLeft(Self.LayerName)+Self.Width/2 , ViewportRight(Self.LayerName) - Self.Width/2)
Y : clamp( Self.Y, ViewportTop(Self.LayerName)+Self.Height/2 , ViewportBottom(Self.LayerName) - Self.Height/2)
B
14
S
6
G
5
Posts: 3
Reputation: 3,506

Post » Thu Sep 01, 2016 9:40 pm

That looks about right. Although there is a bound to layout behavior that seems more suitable for what you described.

I'm not certain about the effects of the layout scale, but that should be easy to compensate for either way, as there is a layoutscale expression you can use as a multiplier if necessary.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Fri Sep 02, 2016 12:58 am

oosyrag wrote:That looks about right. Although there is a bound to layout behavior that seems more suitable for what you described.

I'm not certain about the effects of the layout scale, but that should be easy to compensate for either way, as there is a layoutscale expression you can use as a multiplier if necessary.



Thanks! I’ll try to post a capx up here. There seems to be quite a few people asking about pinch to zoom combined with smooth (inertia) panning / touch drag, while still being able to keep the image within the viewport / layout.

I’m basically trying to create a fullscreen map with touch panning, pinch to zoom, and hopefully rotation, while still keeping it within viewport or layout bounds, and have hotspots that when clicked on have a scrollTo behavior. I’ll see what I can come up with.
B
14
S
6
G
5
Posts: 3
Reputation: 3,506

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 32 guests