[libgdx] Added Skin#removeAttachment.

This commit is contained in:
NathanSweet 2018-11-11 23:45:51 +01:00
parent 3c61589312
commit b194dbf2c8

View File

@ -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;