Help in Scroll Behaviour

  • Hello Everyone,

    We have a project (please find it here) where we have a camera with a scrollto behaviour. Our main goal is to restrict the focus of the camera to a particular rectangular box(9PATCH) and place it into the center of the view-port.

    For that we tried the below logic

    Logic Source: construct.net/en/forum/construct-3/general-discussion-7/avoid-blank-space-platformer-143872

    However the issue is whenever we enabled the scrollto behavior, the game wont start from the center of the view-port.

    Please help.

    Tagged:

  • have you tried this?

    + System: On start of layout

    -> System: Scroll to (ViewportWidth("Player")÷2, ViewportHeight("Player")÷2)

  • There are lots of mistakes in those expressions. Fixed:

    X: clamp(Player.X, RectangleFocusArea.BBoxLeft+ViewportWidth("Player")/2, RectangleFocusArea.BBoxRight-ViewportWidth("Player")/2)

    Y: clamp(Player.Y, RectangleFocusArea.BBoxTop+ViewportHeight("Player")/2, RectangleFocusArea.BBoxBottom-ViewportHeight("Player")/2)

    Also, the size of RectangleFocusArea needs to be larger than the window (viewport) size, otherwise clamp will not work.

  • Also, check out this demo:

    dropbox.com/s/ityy4s958d14x7k/PlatformScrollZones.c3p

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are lots of mistakes in those expressions. Fixed:

    X: clamp(Player.X, RectangleFocusArea.BBoxLeft+ViewportWidth("Player")/2, RectangleFocusArea.BBoxRight-ViewportWidth("Player")/2)

    Y: clamp(Player.Y, RectangleFocusArea.BBoxTop+ViewportHeight("Player")/2, RectangleFocusArea.BBoxBottom-ViewportHeight("Player")/2)

    Also, the size of RectangleFocusArea needs to be larger than the window (viewport) size, otherwise clamp will not work.

    Thanks dop2000 For you prompt response, Could you help us over this weird issue, Please find the file over here.

    Having said that,our requirement is to place the whole game to center of view port because in the modern smartphone the aspect ratio is varied device to device,we are currently have the view port 16:9

    If the whole game wont stay on the center then on the device which doesn't feature 16:9 display, then the background will looks weird. We want to fill the vacant display with a BG whenever the phone screen reach beyond 16:9.

  • have you tried this?

    + System: On start of layout

    -> System: Scroll to (ViewportWidth("Player")÷2, ViewportHeight("Player")÷2)

    Thank You, Did you mean on both the axis?

  • You need to enable Unbounded Scrolling on the layout. Also set scaling mode to Scale Outer. See this tutorial:

    construct.net/en/tutorials/supporting-multiple-screen-sizes-77

  • You need to enable Unbounded Scrolling on the layout. Also set scaling mode to Scale Outer. See this tutorial:

    https://www.construct.net/en/tutorials/supporting-multiple-screen-sizes-77

    Thank You, We have already enabled the Unbound scrolling as well the Scale Outer, Please check the previous post where we have uploaded the .c3p

    Thank you. :)

  • If the viewport is wider than RectangleFocusArea size, then simply set scroll X to the center of the viewport/layout. The view will be centered and only scroll vertically.

  • Either

    X=LayoutWidth/2

    or

    X=RectangleFocusArea.X+RectangleFocusArea.Width/2

    Will probably work

  • If the viewport is wider than RectangleFocusArea size, then simply set scroll X to the center of the viewport/layout. The view will be centered and only scroll vertically.

    We tried multiple times but it didnt work as expected.

    Please help us dop2000

  • If you don't need to scroll horizontally, then simply don't do it. Remove all those actions and set the Y scroll only:

    Set scroll Y: clamp(Player.Y, RectangleFocusArea.BBoxTop+ViewportHeight("Player")/2, RectangleFocusArea.BBoxBottom-ViewportHeight("Player")/2)

  • If you don't need to scroll horizontally, then simply don't do it. Remove all those actions and set the Y scroll only:

    Set scroll Y: clamp(Player.Y, RectangleFocusArea.BBoxTop+ViewportHeight("Player")/2, RectangleFocusArea.BBoxBottom-ViewportHeight("Player")/2)

    Thank You Very much dop2000. It worked like charm.

    Highly appreciated to you and every one who help us in assisting on it :)

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