Camera zoom and scroll, i need example please

Please give me an example of zooming the camera with 2 fingers and scrolling the scene left and right when you click on the screen with 1 finger or mouse

Preferably without installing additional assets

That is a tall order. What have you tried so far?

You need to enable multi-touch:

You need to track the pressed position of two touch points. When the two touch points move you calculate the distance between the two points (use vmath.length) and divide it by the initial distance of the touch points. This will give you a zoom value.

Use a fixed projection so that you can control the zoom: The render pipeline in Defold

Again, you need to track the pressed position of one touch point. When the point moves you calculate the difference and throw away the value on the y-axis and only use the x-value to scroll left/right.

5 Likes

https://britzl.github.io/publicexamples/drag_to_scroll/index.html

https://britzl.github.io/Orthographic/index.html

how could I forget this ((

Well, you said “Preferably without installing additional assets” which is why I didn’t bother mentioning them.

1 Like

this asset is possible ))