How do I limit scrolling on a layout?

0 favourites
  • 6 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Let me explain my problem.

    This is how my lookout looks like:

    http://i.imgur.com/nIkYi91.png

    • On start of layout the camera is scrolled to the middle of the black rectangle (1080x1920px).
    • When double tapped you zoom in to an area (2x) and are able to move around. Double tap again to set zoom to 1x and scroll to the middle of the black rectangle again.

    I've figured out the 2 things above. But I don't know how to limit zooming in and scrolling around to the black area only. I don't want the player to see the white area at all.

    Anyone knows a good solution for this? <img src="{SMILIES_PATH}/icon_e_confused.gif" alt=":?" title="Confused">

  • I've found a solution myself. I'm using the "Boundary" plugin by rex. Not 100% perfect but it works.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Turaco

    I recently was working on doing something very similar - although I was also trying to use the entire screen (regardless of device size or orientation) by using Scale Outer and Unbounded scrolling (which added an extra level of complexity that took me an entire long weekend to work out).

    it is just a matter of calculating how far the layout is allowed to scroll, and keeping within those limits.

    So, here is how I would do what you were asking - no plugins required:

    http://www.rieperts.com/games/forum/ScrollLimit.capx

    this version does the double tap to zoom you mentioned, but I also included how I track multiple touch points, and do pinch to zoom... I also added a button to turn the limit feature on and off so that you can see that it really works.

  • AllanR Thanks a lot. Although I think I'll keep using the plugin because it's simpler (you just set boundaries to image points of an object -background picture). Also I noticed when I zoom in in your project I always get to the middle of the layout and not the point i clicked.

    My problem is that my zooming in isn't instantaneous but over time. So when I zoom onto target location where my boundaries cut off, I get kinda shaky animation of zooming in.

    Thanks for the effort tho.

  • You could use scale rate

  • What you want to do is make a global variable called GameScale (or whatever you want) and on the mousewheel up or mousewheel down condition dictated events that you create remember to make a system>compare two values gamescale > or < than so you can limit the zoom on these mousewheel events. Okay, now do a System> Every Tick event and then a System>Set Layer Scale set your layer to lerp(Layerscale(0), GameScale, 0.03) for layer 0 and if your more than one layer than system>set layer scale> to layerscale 0 for all other layers.

    Tada a smooth camera!

    My source for this information is the examples that come with Construct 2: RTS / Driving Game Template.

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