Search in sources :

Example 1 with SpineDataObject

use of games.rednblack.h2d.extension.spine.SpineDataObject in project HyperLap2D by rednblackgames.

the class SpineActor method initSkeletonData.

private void initSkeletonData() {
    SpineDataObject spineDataObject = (SpineDataObject) irr.getExternalItemType(SpineItemType.SPINE_TYPE, animationName);
    skeletonJson = spineDataObject.skeletonJson;
    skeletonData = spineDataObject.skeletonData;
}
Also used : SpineDataObject(games.rednblack.h2d.extension.spine.SpineDataObject)

Example 2 with SpineDataObject

use of games.rednblack.h2d.extension.spine.SpineDataObject in project HyperLap2D by rednblackgames.

the class ResourceManager method loadCurrentProjectSpineAnimations.

private void loadCurrentProjectSpineAnimations(String path) {
    spineAnimAtlases.clear();
    FileHandle sourceDir = new FileHandle(path);
    SpineDrawableLogic spineDrawableLogic = (SpineDrawableLogic) Sandbox.getInstance().sceneControl.sceneLoader.getExternalItemType(SpineItemType.SPINE_TYPE).getDrawable();
    for (FileHandle entry : sourceDir.list()) {
        if (entry.file().isDirectory()) {
            String animName = FilenameUtils.removeExtension(entry.file().getName());
            FileHandle animJsonFile = Gdx.files.internal(entry.file().getAbsolutePath() + File.separator + animName + ".json");
            SpineDataObject spineDataObject = new SpineDataObject();
            spineDataObject.skeletonJson = new SkeletonJson(new ResourceRetrieverAttachmentLoader(animName, this, spineDrawableLogic));
            spineDataObject.skeletonData = spineDataObject.skeletonJson.readSkeletonData(animJsonFile);
            spineAnimAtlases.put(animName, spineDataObject);
        }
    }
}
Also used : SpineDrawableLogic(games.rednblack.h2d.extension.spine.SpineDrawableLogic) ResourceRetrieverAttachmentLoader(games.rednblack.h2d.extension.spine.ResourceRetrieverAttachmentLoader) FileHandle(com.badlogic.gdx.files.FileHandle) SkeletonJson(com.esotericsoftware.spine.SkeletonJson) SpineDataObject(games.rednblack.h2d.extension.spine.SpineDataObject)

Example 3 with SpineDataObject

use of games.rednblack.h2d.extension.spine.SpineDataObject in project HyperLap2D by rednblackgames.

the class ResourcesManager method getSpineDrawable.

public SpineDrawable getSpineDrawable(String name) {
    if (spineDrawableCache.get(name) == null) {
        SpineDataObject spineDataObject = (SpineDataObject) tiledPlugin.getAPI().getSceneLoader().getRm().getExternalItemType(SpineItemType.SPINE_TYPE, name);
        SkeletonData skeletonData = spineDataObject.skeletonData;
        Skeleton skeleton = new Skeleton(skeletonData);
        spineDrawableCache.put(name, new SpineDrawable(skeleton, skeletonRenderer));
    }
    return spineDrawableCache.get(name);
}
Also used : SpineDrawable(games.rednblack.editor.plugin.tiled.view.SpineDrawable) Skeleton(com.esotericsoftware.spine.Skeleton) SkeletonData(com.esotericsoftware.spine.SkeletonData) SpineDataObject(games.rednblack.h2d.extension.spine.SpineDataObject)

Example 4 with SpineDataObject

use of games.rednblack.h2d.extension.spine.SpineDataObject in project HyperLap2D by rednblackgames.

the class SpineDrawStrategy method updateTile.

@Override
public void updateTile(int entity) {
    if (!checkValidTile(entity))
        return;
    SpineComponent spineComponent = ComponentRetriever.get(entity, SpineComponent.class, tiledPlugin.getAPI().getEngine());
    if (!spineComponent.animationName.equals(tiledPlugin.getSelectedTileName())) {
        replaceSpineCommandBuilder.begin(entity);
        String animName = tiledPlugin.getSelectedTileName();
        replaceSpineCommandBuilder.setAnimationName(animName);
        SpineDataObject spineDataObject = (SpineDataObject) tiledPlugin.getAPI().getSceneLoader().getRm().getExternalItemType(SpineItemType.SPINE_TYPE, animName);
        replaceSpineCommandBuilder.setSkeletonJson(spineDataObject.skeletonJson);
        SkeletonData skeletonData = spineDataObject.skeletonData;
        replaceSpineCommandBuilder.setSkeleton(new Skeleton(skeletonData));
        replaceSpineCommandBuilder.execute(tiledPlugin.facade);
    }
}
Also used : Skeleton(com.esotericsoftware.spine.Skeleton) SpineComponent(games.rednblack.h2d.extension.spine.SpineComponent) SkeletonData(com.esotericsoftware.spine.SkeletonData) SpineDataObject(games.rednblack.h2d.extension.spine.SpineDataObject)

Aggregations

SpineDataObject (games.rednblack.h2d.extension.spine.SpineDataObject)4 Skeleton (com.esotericsoftware.spine.Skeleton)2 SkeletonData (com.esotericsoftware.spine.SkeletonData)2 FileHandle (com.badlogic.gdx.files.FileHandle)1 SkeletonJson (com.esotericsoftware.spine.SkeletonJson)1 SpineDrawable (games.rednblack.editor.plugin.tiled.view.SpineDrawable)1 ResourceRetrieverAttachmentLoader (games.rednblack.h2d.extension.spine.ResourceRetrieverAttachmentLoader)1 SpineComponent (games.rednblack.h2d.extension.spine.SpineComponent)1 SpineDrawableLogic (games.rednblack.h2d.extension.spine.SpineDrawableLogic)1