Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.x] Implement OS agnostic InputEventGesture with Pan, Pinch, and Twist#37754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jeremyz wants to merge3 commits intogodotengine:3.x
base:3.x
Choose a base branch
Loading
fromjeremyz:input-gesture

Conversation

@jeremyz
Copy link
Contributor

this is shamelessy inspired by Federico-Ciuffardi's job on#36953

I have some ideas to implement thresholds to limit the amount of
emitted events but it will be implemented later.

this to be linked to#13139

rakkarage and Sharkalien reacted with thumbs up emojiZireael07, dave2, OverloadedOrama, tuckersn, Federico-Ciuffardi, boruok, and Sharkalien reacted with hooray emoji
@jeremyz
Copy link
ContributorAuthor

jeremyz commentedJun 15, 2020
edited by Calinou
Loading

[gd_scene load_steps=3 format=2][ext_resource path="res://icon.png" type="Texture" id=1][sub_resource type="GDScript" id=1]script/source = "extends Node2Dconst MAX_ZOOM = 0.5const MIN_ZOOM = 0.1onready var cam = $Camerafunc _ready():cam.zoom.x = 0.2cam.zoom.y = 0.2func _unhandled_input(e):if e is InputEventGesturePan:        _move(e)elif e is InputEventGestureTwist:        _rotate(e)elif e is InputEventGesturePinch:        _zoom(e)func _move(event):cam.offset -= (event.get_delta() * cam.zoom).rotated(cam.rotation)func _rotate(event):var fccp = (event.position - get_camera_center_offset())var fccp_op_rot =  - fccp.rotated(event.rotation)cam.offset -= ((fccp_op_rot + fccp) * cam.zoom).rotated(cam.rotation - event.rotation)cam.rotation -= event.rotationfunc _zoom(event):var zf = clamp(cam.zoom.x * event.factor, MIN_ZOOM, MAX_ZOOM)var zd = zf - cam.zoom.xvar from_camera_center_pos = event.position - get_camera_center_offset()cam.offset -= (from_camera_center_pos * zd).rotated(cam.rotation)cam.zoom = zf * Vector2.ONEfunc camera2global(position):var camera_center = cam.global_position + cam.offsetvar from_camera_center_pos = position - get_camera_center_offset()return camera_center + (from_camera_center_pos * cam.zoom).rotated(cam.rotation)func get_camera_center_offset():return get_viewport().get_visible_rect().size / 2"[node name="Node" type="Node2D"]script = SubResource( 1 )[node name="Sprite" type="Sprite" parent="."]texture = ExtResource( 1 )[node name="Camera" type="Camera2D" parent="."]rotating = truecurrent = true

@jeremyzjeremyz requested a review froma team as acode ownerMarch 12, 2021 12:26
Base automatically changed from3.2 to3.xMarch 16, 2021 11:11
@aaronfrankeaaronfranke modified the milestones:3.2,3.3Mar 16, 2021
@akien-mgaakien-mga modified the milestones:3.3,3.4Mar 26, 2021
@CalinouCalinou changed the titleimplement EventGesturePan,Pinch,Twist - OS agnosticimplement EventGesturePan,Pinch,Twist - OS agnostic (3.x)Jul 16, 2021
@jeremyzjeremyzforce-pushed theinput-gesture branch 9 times, most recently from099f122 to268e65dCompareNovember 1, 2021 12:09
@ChaosusChaosus modified the milestones:3.4,3.5Nov 8, 2021
@akien-mgaakien-mga changed the titleimplement EventGesturePan,Pinch,Twist - OS agnostic (3.x)[3.x] Implement OS agnostic InputEventGesture with Pan, Pinch, and TwistNov 10, 2021
@akien-mga
Copy link
Member

For the record, I plan to focus on getting#39055 finalized and merged first, then we can update and merge this PR too for 3.5 ideally.

When we get to it though, we might need to change some things for 3.x specifically to avoid breaking compatibility (i.e. keeping the old names for the existing events and just update their implementation + add Twist).

jeremyz reacted with thumbs up emoji

@MuubNito
Copy link

For the record, I plan to focus on getting#39055 finalized and merged first, then we can update and merge this PR too for 3.5 ideally.

When we get to it though, we might need to change some things for 3.x specifically to avoid breaking compatibility (i.e. keeping the old names for the existing events and just update their implementation + add Twist).

Dude, im sorry but good luck getting this pr finished anytime...

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

3.x

Development

Successfully merging this pull request may close these issues.

6 participants

@jeremyz@akien-mga@MuubNito@aaronfranke@Chaosus@madmiraal

[8]ページ先頭

©2009-2025 Movatter.jp