Zooming in and out on cellphone - What signals?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Thrallherd

Hello,

I would like to allow zooming in and out on cellphone. What signals should I look for? I guess zooming in would be triggered by two fingers getting closer on the screen, while zooming out would be triggered by two fingers getting farther away.

Thank you for your help.

:bust_in_silhouette: Reply From: Magso

InputEventScreenTouch has the index property so you should be able to check the index number, get the two positions and get the length of position 0 - position 1

var positions : Array = [Vector2(), Vector2()]

func _input(event):
    if event is InputEventScreenTouch:
        positions[event.index] = event.position
        if event.index == 1:
            var zoom_amount = (positions[0] - positions[1]).length()

(I’ve not tested this though)

Thank you for your help. Your reply is in alignment with the other reply :slight_smile:

Thrallherd | 2020-05-02 09:49

:bust_in_silhouette: Reply From: kidscancode

You might find this helpful: http://godotrecipes.com/2d/touchscreen_camera/

Thank you for your reply. Unfortunately, even though I enabled “Emulate Touch From Mouse”, the camera doesn’t move when I click around the target. I’m not sure what’s wrong. I did specify a target.

Thrallherd | 2020-05-02 09:47

Make sure you don’t have a Control node intercepting the mouse/touch events.

kidscancode | 2020-05-02 15:59