2

In my stage I have several actors added. I have Input Processor set for actors as well as for the stage itself.

The problem is that, when I tap on the actor the hit method of the actor receives quite big x and y values (I can see this while debugging) and that means these x and y weren't converted to appropriate coordinates in actor's coordinate system. The documentation states vice version.

Do I miss something in there? Any help is appreciated.

Ruzanna
  • 9,766
  • 4
  • 18
  • 23

2 Answers2

0

I had a lot of problems with my project and the position of the actors.

Try to use stageToLocalCoordinates, localToParentCoordinates of the group if your Actor is grouped.

If it's a only Actor, try to override the setX and setY or setPosition method and put your coordinates in the constructor of the Actor. This has worked for my. With this method the Actor will have the same coordinates system that the Stage.

0

Use

Vector2 coords = stage.screenToStageCoordinates(new Vector2(Gdx.input.getX(), Gdx.input.getY()));

then use coords.x and coords.y as your new coordinates in stage.hit() function

JoM
  • 545
  • 4
  • 11