How do I do a smooth Pinch/Zoom ?

0 favourites
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hello, I've been using C2 for a while now but never had to do this thing so far and I still have trouble understanding how lerp and dt can be combined together....

    What I'm trying to achieve is a zoom in/out with two fingers, by pinching, and it should be smooth. Inertia would be an extra bonus. I've been at it the whole day, looked for examples and outdated unreachable .capx examples... I can't figure it out...

    I know there is a .capx example in Construct 2 but it is not smooth at all and makes for a stuttering zoom... Can you help me?

  • Have you tried my demo? I posted it here a few times:

    dropbox.com/s/p40ibb75m9g8z8j/ZoomTouch.capx

    Run in Chrome, it may not work very well in Firefox due to some bug with touches getting "stuck".

  • It looks very much like what I was hoping for and so much simpler than the Construct 2 example! I can't test it right now but I'll let you know as soon as I imported it. Thanks!

  • Yup, indeed, that did the trick! Thank you very much for your help!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Have you tried my demo? I posted it here a few times:

    https://www.dropbox.com/s/p40ibb75m9g8z8j/ZoomTouch.capx?dl=0

    Run in Chrome, it may not work very well in Firefox due to some bug with touches getting "stuck".

    Very nice DOP, thanks a lot for this. Is it possible to zoom through pinch out/in touch only one blue box instead of whole layout?

  • Sure, create a variable "blueBoxScale" and change it the same way. Set sprite scale to this variable.

  • Sure, create a variable "blueBoxScale" and change it the same way. Set sprite scale to this variable.

    Thanks I will try it and share here if it works.

  • Just in case your Dropbox file gets deleted one day, I'm posting the event view here so that people will still be able to re-create it:

    https://i.imgur.com/cN6Qv0w.jpg

  • Just in case your Dropbox file gets deleted one day, I'm posting the event view here so that people will still be able to re-create it:

    https://i.imgur.com/cN6Qv0w.jpg

    Wonderful idea, thanks.

  • Sure, create a variable "blueBoxScale" and change it the same way. Set sprite scale to this variable.

    Hi Dop, I tried this but not working. DOnt know what wrong I am doing. Here is my capx.

    touch.affle.com/explorations/mohan/capx/zoomimagetouch.capx

  • Try this:

    dropbox.com/s/t05m2m2dujbrvas/zoom_sprite.capx

    You can also scale individual layers.

  • Try this:

    https://www.dropbox.com/s/t05m2m2dujbrvas/zoom_sprite.capx?dl=0

    You can also scale individual layers.

    Thanks DOP, you solution seems to be working fine but it allows user to pinch anywhere on screen and scaling starts of blue box. Can I make it like only pinching box make it scale in/out. For example I have two blue boxes and I want to pinch zoom out box 1 and pinch in box 2 in same layer.

    Is this possible?

  • Yes, everything is possible. Use instance variable instead of the global variable to store scale factor for each box. On first touch check which box is touched (maybe save its UID in another variable), and then in event #2 pick this box by UID and scale this box only.

  • Yes, everything is possible. Use instance variable instead of the global variable to store scale factor for each box. On first touch check which box is touched (maybe save its UID in another variable), and then in event #2 pick this box by UID and scale this box only.

    Ok I am gonna try this.

  • Yes, everything is possible. Use instance variable instead of the global variable to store scale factor for each box. On first touch check which box is touched (maybe save its UID in another variable), and then in event #2 pick this box by UID and scale this box only.

    Hi DOP,

    I tried and now I can zoom in the bluebox, ie. I can pinch to reduce the size of box but not able to make it big by pinch out. attaching capx. i am sure something I am doing wrong. Looking for your guidance here.

    touch.affle.com/explorations/mohan/capx/testtouchzoom.capx

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