OSDN Git Service

Actor, screenToLocalCoordinates.
authorNathanSweet <nathan.sweet@gmail.com>
Mon, 1 Oct 2012 01:56:17 +0000 (18:56 -0700)
committerNathanSweet <nathan.sweet@gmail.com>
Mon, 1 Oct 2012 01:56:17 +0000 (18:56 -0700)
InputEvent, reset button to -1 to reduce confusion for buttons that don't have button (touchDragged).

gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java
gdx/src/com/badlogic/gdx/scenes/scene2d/InputEvent.java

index 7b75f79..d0873ea 100644 (file)
@@ -511,6 +511,13 @@ public class Actor {
                return parent.getChildren().indexOf(this, true);\r
        }\r
 \r
+       /** Transforms the specified point in screen coordinates to the actor's local coordinate system. */\r
+       public Vector2 screenToLocalCoordinates (Vector2 screenCoords) {\r
+               Stage stage = getStage();\r
+               if (stage == null) return screenCoords;\r
+               return stageToLocalCoordinates(stage.screenToStageCoordinates(screenCoords));\r
+       }\r
+\r
        /** Transforms the specified point in the stage's coordinates to the actor's local coordinate system. */\r
        public Vector2 stageToLocalCoordinates (Vector2 stageCoords) {\r
                if (parent == null) return stageCoords;\r
index 3954030..f05ae72 100644 (file)
@@ -30,6 +30,7 @@ public class InputEvent extends Event {
        public void reset () {\r
                super.reset();\r
                relatedActor = null;\r
+               button = -1;\r
        }\r
 \r
        /** The stage x coordinate where the event occured. Valid for: touchDown, touchDragged, touchUp, mouseMoved, enter, and exit. */\r