How do I prevent excess zoom out

0 favourites
  • 4 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • 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:

    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:

    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?

  • Would using the clamp() expression work?

    That way you can give a minimum and maximum value..

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)