Search in sources :

Example 1 with Skin

use of com.esotericsoftware.spine.Skin in project bladecoder-adventure-engine by bladecoder.

the class SpineRenderer method setSkin.

public void setSkin(String skin) {
    // set the skin if the current source is loaded
    if (currentSource != null && currentSource.refCounter > 0) {
        SkeletonCacheEntry sce = (SkeletonCacheEntry) currentSource;
        EngineLogger.debug("Setting Spine skin: " + skin);
        if (skin != null) {
            SkeletonData skeletonData = sce.skeleton.getData();
            if (skin.indexOf(',') == -1 || skeletonData.findSkin(skin) != null) {
                sce.skeleton.setSkin(skin);
            } else {
                // we can combine several skins separated by ','
                String[] skins = skin.split(",");
                Skin combinedSkin = new Skin(skin);
                for (String sk : skins) {
                    // Get the source skins.
                    Skin singleSkin = skeletonData.findSkin(sk.trim());
                    combinedSkin.addSkin(singleSkin);
                }
                // Set and apply the Skin to the skeleton.
                sce.skeleton.setSkin(combinedSkin);
            }
        } else {
            sce.skeleton.setSkin((Skin) null);
        }
    // sce.skeleton.setSlotsToSetupPose();
    }
    this.skin = skin;
}
Also used : Skin(com.esotericsoftware.spine.Skin) SkeletonData(com.esotericsoftware.spine.SkeletonData)

Aggregations

SkeletonData (com.esotericsoftware.spine.SkeletonData)1 Skin (com.esotericsoftware.spine.Skin)1