Help, Pinch Zoom Out Going Too Far

0 favourites
  • 7 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hey everybody! Thanks to this community, I've found posts that taught me how zoom via Touch/Pinch, however I'm having some trouble limiting how far out my pinch zoom goes.

    As you see in the photos. My game is a series of stationary layouts with an image on top. I added a zoom function in case the player needs to examine any details on the image.

    Here's a screenshot of my touch zoom event sheet. You'll see a "Scroll to (430, 158)" Action and that's there just to keep the "zoom" centered on the image.

    Here's what my default layout size/scale/zoom is when each layout loads.

    As I mentioned, when I Zoom in, it also scrolls to the center of the image and that part works perfectly. However, when I Zoom Out, the zooming out goes too far.

    I want to set the Zoom Out to stop at the default settings AND stay centered or at least somehow reset it. I feel like I'm close, but have been working on it for a few hours LOL I can't figure it out.

    Thanks so much for your help!

  • Check the newScale value in a System Event(Equal, Greater Than, Less Than, etc), then in the action under that System Event, set it to your desired maximum zoom out size? I hope that makes sense.

    Basically just checking the zoom value is equal or less than, your desired maximum zoom out specs, then make sure it gets set to that specification. Hopefully this helps, and I didn't make it confusing. Sometimes I have difficulty putting thoughts into words.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • how far it zooms out is the third value in the clamp(currentLayoutScale,minLayoutScale,maxLayoutScale)

    set the max value to something lower, like 1 for default for example.

    to reset the camera to the center of the layout when zoomed out you could do something like this:

    if layoutScale = maxLayoutScale set camera postion or scroll to

    x: lerp(self.x,layout.width/2,speedYouWant*dt)

    y: lerp(self.y,layout.height/2,speedYouWant*dt)

  • how far it zooms out is the third value in the clamp(currentLayoutScale,minLayoutScale,maxLayoutScale)

    set the max value to something lower, like 1 for default for example.

    to reset the camera to the center of the layout when zoomed out you could do something like this:

    if layoutScale = maxLayoutScale set camera postion or scroll to

    x: lerp(self.x,layout.width/2,speedYouWant*dt)

    y: lerp(self.y,layout.height/2,speedYouWant*dt)

    For whatever reason, that didn't work, but thanks you to, I did figure it out. When switching the third value to 1, it didn't zoom in at all, but zoomed out the same (too much). However, by changing the second value to 1 and keeping the third value the same, that did it!

    Thanks!

  • Check the newScale value in a System Event(Equal, Greater Than, Less Than, etc), then in the action under that System Event, set it to your desired maximum zoom out size? I hope that makes sense.

    Basically just checking the zoom value is equal or less than, your desired maximum zoom out specs, then make sure it gets set to that specification. Hopefully this helps, and I didn't make it confusing. Sometimes I have difficulty putting thoughts into words.

    Thanks for the response. I understood it but couldn't exactly apply it. I've very new to Construct so if you have difficulty putting thoughts into words, I have double the difficulty putting words into actions LOL!

  • Haha, not a problem. Happy to try and help. I'm still relatively new to Construct as well, after not using it for years, I'm sort of relearning much of it. Learn something new everyday :). Glad you were able to get it sorted out!

  • Oh yea you are right, I mixed up which way the layoutScale value zooms in/out!

    glad I could help in some way.

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