r81, r82: problem checking if viewport in-bounds

0 favourites
  • 5 posts
From the Asset Store
Design for game, asset for game, game kit, UI design, completed design for game FLY BOUND
  • r81, r82: problem checking if viewport in-bounds on right and lower edges:

    I don't know if this is a bug or my inexperience with this system, but...

    The intention of my capx is to create an in-browser RTS game with left-mouse click-drag for panning, and scroll-wheel zooming, and it is currently a working background with pan and zoom.

    I have working zoom and pan, and with only the need to 'stay in bounds' of the layout being the problem, so when drag-panning, the view-port size/position must be compared to the bounds of the layout, and also while zooming out, the same checks must occur. For reasons explained below, this manual check for bounds must be done. (All is much clearer in the attached capx.)

    RTS pan-zoom test

    Zoom out code works: Since while zooming out, scrollX & scrollY are presumably in-bounds at the beginning, but as the view-port 'grows' actual scrollX (mid-point of the view-port) ends up closer to the edge of the layout, and it can be possible to see the edge of the layout at full zoom-out, so each mouse-wheel-up event checks scrollX and scrollY, and forces the view-port back in-bounds if necessary. Works.

    Scrolling:

    During the scrolling, the mouse is dragging the layout left, or actually the view-port to the right. Here, I started out trying to compare the value that is 'about' to be applied to see if it is in-bounds, and then only apply values to scrollX & scrollY that are in-bounds. Works on the left and upper bounds, but not the lower and right bounds. The only workaround is to just go ahead an apply the value regardless, THEN do the checks in the same way as the zoom-out code does, comparing the actual scrollX & scrollY values to see if they have gotten out of bounds, and THEN forcing them back in again.

    Finally, all attempts to use both zooming and the Unbounded scrolling : OFF feature were a failure. EVEN with the workaround in place where the code appears to keep the view-port in-bounds at all times, if Unbounded scrolling is set to NO, very weird interactions occur when zoomed out (about 0.3 to 0.1 scaling). When zoomed at 1.0 or near to it, the auto-bounds is fine.

    So to recap:

    With the initial method, the view-port can be dragged infinitely to the right or down, but the upper and left bounds work fine. If out of bounds to the right or bottom, the moment the zoom-out code is triggered, it is forced back in-bounds, as checking against scrollX works fine.

  • In the capx, it works as intended as saved. un-comment the commented section in the scrolling group to see the problem. Also, set Unbounded scrolling to NO to see the problem with auto-bounding when zoomed in.

    Due to the current layout.y size bug, I couldn't make it as big as I wanted, but it should be fine to demonstrate the problem.

    Also, since I currently have a working version, is the multi-layer x,y,& z parallax effect a good subject for a tutorial? If it hasn't been covered, I'll do one.

    Thanks,

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm pretty sure the exact same behavior was present in r81, especially the auto-bounds when zoomed in problem. But testing today was on r82. I tried this on Vista 64 and Win7 64, both times in a Chrome browser, both with r82. I believe that the Win7 system has the latest 32-bit Java for running Processing.js in Chrome.

  • I'm not clear that this is a C2 bug and not just a problem with your events. If Unbounded Scrolling is set to Yes, all bounding is done by events. So isn't this just an issue with your events?

  • There are actually two issues described above:

    Yes, when Unbounded Scrolling is set to YES, the event handling on my side I JUST now discovered, is at fault. (rookie Construct mistake, I know: missing the Else-ness in my logic.)

    However, the behavior when Unbounded Scrolling is set to NO is seemingly completely messed up when zoomed in at about scaling less than .5 in my app. (Try the newly edited capx with Unbounded Scrolling set to YES, then set it to NO and scroll 'down'/zoom in to observe this.) So even though the current code never sets ScrollX & ScrollY out-of-bounds while dragging due to the above bounds checking, the auto-bounds setting seems to be erroneously forcing the viewport well out-of-bounds when zoomed all the way in (scaling of 0.1).

    http://dl.dropbox.com/u/67882392/MyRTS%20zoom-pan.capx

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