flame icon indicating copy to clipboard operation
flame copied to clipboard

ScaleDetector and HasDraggable Components use ScaleDetector without a pointer

Open 550116619 opened this issue 2 years ago • 10 comments

I want to realize a function. A map is similar to Baidu Map. One finger can move it, and two fingers can zoom it. In the case of the official website, there is only one ScaleDetector. I can't drag it accurately, so I use HasDraggable Components, but ScaleDetector can't be used. My most desired function is to know the moving coordinates of two fingers. I can handle scaling by myself, or I can use ScaleDetector, But now it can't finish my work

550116619 avatar Feb 20 '23 13:02 550116619

Hi, we only accept issues in English unfortunately. If you translate this to English and notify me I can re-open it.

spydon avatar Feb 20 '23 13:02 spydon

Hi, we only accept issues in English unfortunately. If you translate this to English and notify me I can re-open it.

I have translated it into English, thank you

550116619 avatar Feb 20 '23 14:02 550116619

Thanks for translating it. You can use the MultiTouchDragDetector for this if you just want to know the coordinates of several fingers.

You should also be able to get all the information that you need from the ScaleDetector since it also handles pans/drags: https://docs.flame-engine.org/1.6.0/flame/inputs/gesture_input.html?highlight=gestures#pandetector-and-scaledetector

spydon avatar Feb 20 '23 14:02 spydon

Thanks for translating it. You can use the MultiTouchDragDetector for this if you just want to know the coordinates of several fingers.

You should also be able to get all the information that you need from the ScaleDetector since it also handles pans/drags: https://docs.flame-engine.org/1.6.0/flame/inputs/gesture_input.html?highlight=gestures#pandetector-and-scaledetector

I use FlameGame, which does not recommend MultiTouchDragDetector. I need the drag function of HasDraggableComponents. I have studied the example of this link and can't drag my components accurately

550116619 avatar Feb 20 '23 15:02 550116619

Thanks for translating it. You can use the MultiTouchDragDetector for this if you just want to know the coordinates of several fingers.

You should also be able to get all the information that you need from the ScaleDetector since it also handles pans/drags: https://docs.flame-engine.org/1.6.0/flame/inputs/gesture_input.html?highlight=gestures#pandetector-and-scaledetector

ScaleDetector cannot locate the movement of a component. For example, if there is a fixed component, moving the pointer on the top will move the component on the bottom. This is not what I want, and the scaling effect is not ideal. I want to really scale, rather than just monitor the scaling of saleY or saleX

550116619 avatar Feb 20 '23 15:02 550116619

I'm not sure that I understand fully what you want to do, do you want to be able to register drag events on top of components and at the same time be able to react on scale events?

If that is what you want to do you can continue to use the HasDraggableComponents and override the onDragUpdate method in your FlameGame (remember to call super), in the event of that method you will be able to get the pointerId and position of the pointer, with which you should be able to build scaling logic from. Not a very simple solution, but there isn't any simpler way currently if you want to use the HasDraggableComponents mixin.

spydon avatar Feb 20 '23 15:02 spydon

I'm not sure that I understand fully what you want to do, do you want to be able to register drag events on top of components and at the same time be able to react on scale changes?

If that is what you want to do you can continue to use the HasDraggableComponents and override the onDragUpdate method in your FlameGame (remember to call super), in the event of that method you will be able to get the pointerId and position of the pointer, with which you should be able to build scaling logic from. Not a very simple solution, but there isn't any simpler way currently if you want to use the HasDraggableComponents mixin.

Similar to Google Map as my game map, which supports drag and zoom, onDragUpdate can only get the position of one pointer, and can't judge the number of pointers. How can I get the position and number of two pointers? This method gives me too little information

550116619 avatar Feb 20 '23 15:02 550116619

In the event (the argument for onDragUpdate) you can get the pointerId then you'll have to store that with appropriate information about the position, which you also get from the event, to be able to create scaling logic.

spydon avatar Feb 20 '23 16:02 spydon

In the event (the argument for onDragUpdate) you can get the pointerId then you'll have to store that with appropriate information about the position, which you also get from the event, to be able to create scaling logic.

How can I get the relevant position? In what way, I can only get one coordinate. I should get two coordinates to know whether it is scaling

550116619 avatar Feb 21 '23 04:02 550116619

How can I get the relevant position? In what way, I can only get one coordinate. I should get two coordinates to know whether it is scaling

Like I said, you have to store the position for each pointerId, since they come in with different events.

spydon avatar Feb 21 '23 07:02 spydon