OSDN Git Service

Added Skin methods to clone a drawable.
authorNathanSweet <nathan.sweet@gmail.com>
Tue, 28 Aug 2012 05:09:47 +0000 (22:09 -0700)
committerNathanSweet <nathan.sweet@gmail.com>
Tue, 28 Aug 2012 05:09:47 +0000 (22:09 -0700)
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Skin.java

index d1a3293..f821e63 100644 (file)
@@ -296,7 +296,21 @@ public class Skin implements Disposable {
 \r
        /** Returns a copy of a drawable found in the skin via {@link #getDrawable(String)}. */\r
        public Drawable newDrawable (String name) {\r
-               Drawable drawable = getDrawable(name);\r
+               return newDrawable(getDrawable(name));\r
+       }\r
+\r
+       /** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */\r
+       public Drawable newDrawable (String name, float r, float g, float b, float a) {\r
+               return newDrawable(getDrawable(name), new Color(r, g, b, a));\r
+       }\r
+\r
+       /** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */\r
+       public Drawable newDrawable (String name, Color tint) {\r
+               return newDrawable(getDrawable(name), tint);\r
+       }\r
+\r
+       /** Returns a copy of the specified drawable. */\r
+       public Drawable newDrawable (Drawable drawable) {\r
                if (drawable instanceof TextureRegionDrawable) return new TextureRegionDrawable((TextureRegionDrawable)drawable);\r
                if (drawable instanceof NinePatchDrawable) return new NinePatchDrawable((NinePatchDrawable)drawable);\r
                if (drawable instanceof SpriteDrawable) return new SpriteDrawable((SpriteDrawable)drawable);\r
@@ -304,13 +318,12 @@ public class Skin implements Disposable {
        }\r
 \r
        /** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */\r
-       public Drawable newDrawable (String name, float r, float g, float b, float a) {\r
-               return newDrawable(name, new Color(r, g, b, a));\r
+       public Drawable newDrawable (Drawable drawable, float r, float g, float b, float a) {\r
+               return newDrawable(drawable, new Color(r, g, b, a));\r
        }\r
 \r
        /** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */\r
-       public Drawable newDrawable (String name, Color tint) {\r
-               Drawable drawable = getDrawable(name);\r
+       public Drawable newDrawable (Drawable drawable, Color tint) {\r
                if (drawable instanceof TextureRegionDrawable) {\r
                        Sprite sprite = new Sprite(((TextureRegionDrawable)drawable).getRegion());\r
                        sprite.setColor(tint);\r