OSDN Git Service

[added] minor additions to rect and vec2.
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sun, 1 May 2011 11:45:18 +0000 (11:45 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sun, 1 May 2011 11:45:18 +0000 (11:45 +0000)
gdx/src/com/badlogic/gdx/graphics/g2d/TextureRegion.java
gdx/src/com/badlogic/gdx/math/Rectangle.java
gdx/src/com/badlogic/gdx/math/Vector2.java

index ff52a8b..95847a1 100644 (file)
@@ -201,7 +201,7 @@ public class TextureRegion {
                        float temp = v;\r
                        v = v2;\r
                        v2 = temp;\r
-               }\r
+               }               \r
        }\r
 \r
        /**\r
index 343b926..f540ec2 100644 (file)
@@ -142,4 +142,11 @@ public class Rectangle implements Serializable {
                                        y > rectangle.y + rectangle.height || \r
                                        y + height < rectangle.y);\r
        }\r
+\r
+       public void set (int x, int y, int width, int height) {\r
+               this.x = x;\r
+               this.y = y;\r
+               this.width = width;\r
+               this.height = height;           \r
+       }\r
 }\r
index 85efdb4..17400ce 100644 (file)
@@ -286,4 +286,18 @@ public class Vector2 implements Serializable {
       \r
       return this;\r
   }\r
+   \r
+       /**\r
+        * Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored\r
+        * in this vector.\r
+        * \r
+        * @param target The target vector\r
+        * @param alpha The interpolation coefficient\r
+        * @return This vector for chaining.\r
+        */\r
+       public Vector2 lerp (Vector2 target, float alpha) {\r
+               Vector2 r = this.mul(1.0f - alpha);\r
+               r.add(target.tmp().mul(alpha));\r
+               return r;\r
+       }\r
 }\r