OSDN Git Service

added setAngle(float) to Vector2
authorAriel Coppes <ariel.coppes@gemserk.com>
Mon, 8 Oct 2012 23:05:47 +0000 (21:05 -0200)
committerAriel Coppes <ariel.coppes@gemserk.com>
Mon, 8 Oct 2012 23:05:47 +0000 (21:05 -0200)
gdx/src/com/badlogic/gdx/math/Vector2.java

index 90e3772..51348d4 100644 (file)
@@ -242,6 +242,13 @@ public class Vector2 implements Serializable {
                if (angle < 0) angle += 360;\r
                return angle;\r
        }\r
+       \r
+       /** Sets the angle of the vector.\r
+        * @param angle The angle to set. */\r
+       public void setAngle (float angle) {\r
+               this.set(len(), 0f);\r
+               this.rotate(angle);\r
+       }\r
 \r
        /** Rotates the Vector2 by the given angle, counter-clockwise.\r
         * @param degrees the angle in degrees */\r