Răsfoiți Sursa

[libgdx] Added Skin#removeAttachment.

NathanSweet 6 ani în urmă
părinte
comite
b194dbf2c8

+ 14 - 0
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skin.java

@@ -34,6 +34,7 @@ import com.badlogic.gdx.utils.Array;
 import com.badlogic.gdx.utils.ObjectMap;
 import com.badlogic.gdx.utils.ObjectMap.Entry;
 import com.badlogic.gdx.utils.Pool;
+
 import com.esotericsoftware.spine.attachments.Attachment;
 
 /** Stores attachments by slot index and attachment name.
@@ -77,6 +78,15 @@ public class Skin {
 		return attachments.get(lookup);
 	}
 
+	/** Removes the attachment in the skin for the specified slot index and name, if any. */
+	public void removeAttachment (int slotIndex, String name) {
+		if (slotIndex < 0) throw new IllegalArgumentException("slotIndex must be >= 0.");
+		Key key = keyPool.obtain();
+		key.set(slotIndex, name);
+		attachments.remove(key);
+		keyPool.free(key);
+	}
+
 	public void findNamesForSlot (int slotIndex, Array<String> names) {
 		if (names == null) throw new IllegalArgumentException("names cannot be null.");
 		if (slotIndex < 0) throw new IllegalArgumentException("slotIndex must be >= 0.");
@@ -97,6 +107,10 @@ public class Skin {
 		attachments.clear(1024);
 	}
 
+	public int size () {
+		return attachments.size;
+	}
+
 	/** The skin's name, which is unique within the skeleton. */
 	public String getName () {
 		return name;