How do I prevent excess zoom out

Get help using Construct 2

Post » Thu Dec 31, 2015 6:04 pm

I'm trying to implement a system where the player can zoom in and out (set the scale) of a layout. I don't want the player to be able to zoom out so far such that the scaled layout is smaller than the window. So I did this (in pseudo code):

Function zoom (float increment) {
if ((LayerScale("map_layer") + increment) * LayoutWidth >= WindowWidth && (LayerScale("map_layer") + increment) * LayoutHeight >= WindowHeight) {
SetLayerScale("map_layer", LayerScale("map_layer") + increment);
}
}

or C2 events:

Image

However, this doesn't work. The value for LayerScale("map_layer") * LayoutWidth gives the width of the layer when scaled, however I can still produce this:

Image

the layer width says it's 1536 and the window width is 1366, but surely if this were the case, then there is enough of the layer to fill the screen. Why is it that there is a white patch where there is no layout?

EDIT: After testing I have found it's to do with the fullscreen mode. I am using Scale outer, can this work with this mode?
Last edited by briggybros on Thu Dec 31, 2015 6:10 pm, edited 1 time in total.
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Thu Dec 31, 2015 6:07 pm

Would using the clamp() expression work?
That way you can give a minimum and maximum value..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 6:16 pm

@LittleStain Would that work though? Setting a constant limit to how zoomed out the map could go would be a bad thing for players with both large and small resolutions. To cater for all resolutions with this surely the zoomout would have to be small so those with large resolutions don't see outside the layout by zooming out too far. But then those with small resolution would not be able to zoom out so much as to make the zoom useful.
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Thu Dec 31, 2015 6:28 pm

briggybros wrote:@LittleStain Would that work though? Setting a constant limit to how zoomed out the map could go would be a bad thing for players with both large and small resolutions. To cater for all resolutions with this surely the zoomout would have to be small so those with large resolutions don't see outside the layout by zooming out too far. But then those with small resolution would not be able to zoom out so much as to make the zoom useful.


You could set the lower and upper values based on windowwidth (resolution) or viewportwidth compared to projectsize , right?

no reason to use a constant limit..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, Mayfly, Yahoo [Bot] and 5 guests