best way to handle gestures in scene2d

Anything libgdx related goes here!

best way to handle gestures in scene2d

Postby TruePlayer » Mon Aug 19, 2019 11:03 pm

I worked with MVC and the screen did the gesture processing there:
Code: Select all
/*********************ОБРАБАТЫВАЕМ И GestureListener И InputProcessor**********************/
InputMultiplexer im = new InputMultiplexer();
GestureDetector gd = new GestureDetector(this);
im.addProcessor(gd);
im.addProcessor(this);
Gdx.input.setInputProcessor(im);
/******************************************************************************************/



now my task is to fully implement only scene2d, tell me how in this case to handle gestures?
I do not need code, I need an idea for understanding.
my specific question is: how to determine the actor that processes the desired gesture, or how, when processing the gesture with a scene, call the desired method from the actor?

I watched a lot of articles and everywhere they do things differently. Do I need to implement interfaces in actors? How will the event be transmitted from the scene to the actor?
TruePlayer
 
Posts: 103
Joined: Sun Jul 28, 2019 12:22 pm

Re: best way to handle gestures in scene2d

Postby TruePlayer » Tue Aug 20, 2019 12:34 am

I’m trying more and more to get involved in scene2d and a gradual understanding of philosophy comes.
did I understand correctly that for processing gestures I don’t need to change anything, but just transfer the methods from the controller to the player?
TruePlayer
 
Posts: 103
Joined: Sun Jul 28, 2019 12:22 pm

Re: best way to handle gestures in scene2d

Postby evilentity » Tue Aug 20, 2019 9:08 am

You can add ActorGestureDetector to the Actor. Keep in mind that will only work if touch starts within actor bounds. Depending on what you want to do it may not be optimal way to do this.

Doing MVC in your first game is massive overkill. Get something working first.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4854
Joined: Wed Aug 24, 2011 11:37 am


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot] and 1 guest