|
|
|
|
Reply From: |
hinasis |
InputEventScreenDrag
is an event that is a complete action.
It has two parameters you need for what you want to do, position
and relative
, well I think relative
is enough for this.
The relative
parameter is a position relative to position
and position
is the start point of the the “swipe” action. So you can check, in your case, if the relative.y
is positive or negative, if it’s negative it’s a “swipe up”, and positive a “swipe down”.
I could be giving you incorrect information, because I haven’t tried it, but it’s what it looks like. The docs are missing information.
It’s probable that there is a better way to catch touch gestures, but I can’t find it.
I mean, ScreenDrag can be a very slow movement, not just a swipe. May be it’s something related to the speed
paramenter.
Yeah thanks
I’m really confused. I get that InputEventScreenDrag has speed, position and relative but I am not even sure how to handle the input if I am also looking for InputEventScreenTouch. The second the screen is touched InputEventScreenTouch must be registered right, so how do I differentiate it.
Also there is very little info regarding speed, is it measured in pixels per second or per frame, what constitutes fast or slow.
As you said the Docs are missing a lot of info.
alfandango | 2018-07-20 23:45
Do you mean something like:
func ready():
your_character.connect("input_event",self,"on_input_event")
func on_input_event(viewport,event,shape_idx):
if event is InputEventScreenTouch && event.pressed:
#blabla
if event is InputEventScreenDrag:
#blabla
Every event pass through it, so you won’t miss any event, touch or drag.
Note: I think the next code works without the signal connection, I’m still a rookie:
func _input_event(viewport,event,shape_idx):
if event is InputEventScreenTouch && event.pressed:
#blabla
if event is InputEventScreenDrag:
#blabla
hinasis | 2018-07-21 04:44
You’ve blown my mind a little here.
Where did you see the your_character.connect("input_event",self,"on_input_event")
? I haven’t seen any documentation on Input handling using such a method.
You’re second snippet may have given me an idea
alfandango | 2018-07-21 07:44
Haha, I said I’m a rookie.
You said your character is a KinematicBody2D that comes from CollisionObject2D that handles its input with the virtual method _input_event()
and emits the input_event
signal, and you are supposed to use that signal outside the node, as I do in most cases delegating inputs to a parent. But here you can just override the method.
I’m confused too! Sorry
hinasis | 2018-07-21 14:08
appreciate the help, I got it to work!
alfandango | 2018-07-21 21:02