Simulate unbounded scrolling?

  • I have a bit of a problem.

    At the beginning of every level, I want to zoom out and show the whole level. This sometimes looks really strange without 'unbounded scrolling' enabled.

    However, when the game is 'zoomed in', the scrolling needs to be bounded so that the player knows when they are near the edge.

    Any help? Perhaps a way to simulate either unbounded or bounded scrolling?

  • You can simulate Bounded scrolling with unbounded with this:

    Scroll to X: Clamp(Sprite.X, WindowWidth/2, LayoutWidth-WindowWidth/2)

    Scroll to Y: Clamp(Sprite.Y, WindowHeight/2, LayoutHeight-WindowHeight/2)

  • Thanks,

    Will I run into any problems with rotating layouts?

  • OK, how would I do this in addition to layer scaling? I scale my main layer during the game and I do not want the player to be able to see outside the layout. R0J0hound?

  • 1. When the layout is rotated it behaves that same as normal bounded scrolling.

    2. Change the formulas like so:

    set scroll x: Clamp(Sprite.X, WindowWidth/(2*LayoutScale), LayoutWidth-WindowWidth/(2*LayoutScale))

    set scroll y: Clamp(Sprite.Y, WindowHeight/(2*LayoutScale), LayoutHeight-WindowHeight/(2*LayoutScale))

    If just the layer is scaled replace LayoutScale with LayerScale(layer).

  • Many thanks, as always.

    I suppose this might be good for the FAQ ;)

  • rojohound, when scaling is implemented, Sometimes I get to places where the layout 'jumps' to an unbounded state as soon as it is rotated a fraction. Very strange.

  • Sorry, name incorrectly. R0J0hound? ^

  • Is it the same effect if you use just c2's built in bounded scrolling? The formula just replicates that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If my window is near the bounds of my layout, scaling my main layer down for a zoom out effect makes the white space outside the layout visible. This corrects itself once I scroll away; I can no longer get outside the bounds when scrolling back to the edges.

    It this a bug, or do I need to use clamp, something else?

  • hi gys...can u solve this problem..I guess its with clamp: basicly its like the bound to layout... but immagine that my layout is 20000 long and high 800. This means that the sprite is blocked on top and bottom...but disappaeras on left or right side since the window view is just 1500*800.... i would need something like "bound to screen" ...did u undersand my problem ? thanks

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