godot_recipes icon indicating copy to clipboard operation
godot_recipes copied to clipboard

[Discussion] Touchscreen camera

Open cbscribe opened this issue 4 years ago • 5 comments

Discussion for http://godotrecipes.com/2d/touchscreen_camera/

cbscribe avatar Feb 03 '21 02:02 cbscribe

Thanks for this. Is there a way to implement this in python? I know how to make the camera pan and move, I just have a slight problem with trying to get pydroid to understand touch using PYX and drawing a d-pad and two-to-four buttons for actions and such. I have searched everywhere and keep bumping into bad examples. I did try using sdl2.touch.get_device from the Pygame reference website, but it looks like stereo instructions.

nemesisnes avatar Nov 05 '21 14:11 nemesisnes

The pan code works great. The zoom code throws an error in Godot 3.4:

The line var drag_distance = events[0].position.distance_to(events[1].position) gives an error of "Invalid get index '0' (on base: 'Dictionary')."

I fixed this by using events.values() to get the values as an array. var drag_distance = events.values()[0].position.distance_to(events.values()[1].position)

kylamon1 avatar Nov 29 '21 13:11 kylamon1

The pan code works great. The zoom code throws an error in Godot 3.4:

The line var drag_distance = events[0].position.distance_to(events[1].position) gives an error of "Invalid get index '0' (on base: 'Dictionary')."

I fixed this by using events.values() to get the values as an array. var drag_distance = events.values()[0].position.distance_to(events.values()[1].position)

You can and should open a pull request to fix this - it's a really good point, since they slightly changed how input events work in 3.4.

WolfgangSenff avatar Nov 29 '21 13:11 WolfgangSenff

I'll be honest, I dont know how to do that. My git hub knowledge is limited to: make a repo, git commit, and git push to main through the desktop app.

kylamon1 avatar Nov 29 '21 16:11 kylamon1

Note that you need to check the Current checkbox on the camera in order for the camera to be active :)

neoncube2 avatar Sep 03 '22 16:09 neoncube2