Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to catch a "click&pull" and "touch&swipe" event? #42

Open
TLINDEN opened this issue Feb 18, 2024 · 3 comments
Open

Is it possible to catch a "click&pull" and "touch&swipe" event? #42

TLINDEN opened this issue Feb 18, 2024 · 3 comments

Comments

@TLINDEN
Copy link

TLINDEN commented Feb 18, 2024

I need the user to be able to click on an object and pull it into some direction. When the user releases the mouse button, the object would move into the desired direction. And I need the same behavior with a touch pad (mobile).

Is this possible with this module somehow?

Thanks in advance,
Tom

@quasilyte
Copy link
Owner

Hi!

There is nothing builtin support for this kind of thing as I'm not sure how it fits a single key/gesture format, but it's quite easy to implement it. With that being said, maybe it will be added one day if there is an elegant way to do it.

This chunk of code handles many kinds of "scrolls" (a very close thing, you can probably see how to adjust it for your needs):
https://github.com/quasilyte/roboden-game/blob/9a5d355f3ddcd0767c9083233bc814f0b54246cf/src/scenes/staging/camera_manager.go#L104-L171

It has middle-mouse button click-and-pull scrolling that you're interested and it works identically on mobiles.

So basically, for mobiles you need to remember the gesture start pos. Then you need to wait until the first tick the action is no longer active (or use "released" event, but I don't think it works with touches right now?). Then you have 2 positions: one from the start and one at the end of the gesture.

For mouse, it's basically the same.

@quasilyte
Copy link
Owner

quasilyte commented May 1, 2024

This specific issue can make the game-side implementation a bit easier (at least for the mouse part of things):
#39

@quasilyte
Copy link
Owner

Regarding the "released" tap inputs: #38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants