Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new JSON format in Spine 3.8 beta #74

Closed
voidware opened this issue Jun 12, 2019 · 4 comments
Closed

Support new JSON format in Spine 3.8 beta #74

voidware opened this issue Jun 12, 2019 · 4 comments

Comments

@voidware
Copy link

No description provided.

@voidware
Copy link
Author

"skins" now appear to be in an array so starting out we need;

allSkins = json.array("skins") ?: throw EndUserException("JSON file doesn't contain skins.")

        // HACK!
        defaultSkin = allSkins[0] ?: throw EndUserException("JSON file doesn't have a default skin.")

Then it doesnt find the mouth images at all. Here's a simple file where i named each one the plain letter;

{
"skeleton": {
	"hash": "1av5ovkDM87arDgCkqSr2HiJT+U",
	"spine": "3.8.19-beta",
	"x": -512.03,
	"y": -512.03,
	"width": 1024.06,
	"height": 1024.06,
	"images": "./images/",
	"audio": ""
},
"bones": [
	{ "name": "root" },
	{
		"name": "mouth",
		"parent": "root",
		"length": 173.79,
		"x": 195.25,
		"y": -172.52,
		"scaleX": 1.3,
		"scaleY": 1.3
	}
],
"slots": [
	{ "name": "head", "bone": "root", "attachment": "head" },
	{ "name": "mouth", "bone": "mouth", "attachment": "a" }
],
"skins": [
	{
		"name": "default",
		"attachments": {
			"head": {
				"head": { "width": 1024, "height": 1024 }
			},
			"mouth": {
				"a": { "y": 0.38, "width": 256, "height": 209 },
				"b": { "y": 0.38, "width": 256, "height": 209 },
				"c": { "y": 0.38, "width": 256, "height": 209 },
				"d": { "y": 0.38, "width": 256, "height": 209 },
				"e": { "y": 0.38, "width": 256, "height": 209 },
				"f": { "y": 0.38, "width": 256, "height": 209 },
				"g": { "y": 0.38, "width": 256, "height": 209 },
				"h": { "y": 0.38, "width": 256, "height": 209 },
				"x": { "y": 0.38, "width": 256, "height": 209 }
			}
		}
	}
],
"events": {
	"event1": {},
	"event2": {}
},
"animations": {
	"animation": {}
}
}

@DanielSWolf
Copy link
Owner

Sorry for the late reply; I was on holiday. Changing the format shouldn't be hard. However, I'll probably need to introduce a version check so that for older file versions, the old logic is still applied.

@voidware
Copy link
Author

Hi
I managed to get it working, but i had to add another change. Looking at the example above, it appears the mouth image attachments are now in a sub-object called "attachments".

Here are my changes:

class SpineJson(private val filePath: Path) {
	private val fileDirectoryPath: Path = filePath.parent
...
	fun getSlotAttachmentNames(slotName: String): List<String> {
        val ahead = defaultSkin.obj("attachments") ?: throw EndUserException("no attachments in skin");
        val attachments = ahead.obj(slotName) ?: JsonObject()
		return attachments.map { it.key }
	}
...

@DanielSWolf DanielSWolf changed the title Spine exporter doesnt work anymore Support new JSON format in Spine 3.8 beta Jul 17, 2019
DanielSWolf added a commit that referenced this issue Jul 17, 2019
@DanielSWolf
Copy link
Owner

I contacted Esoteric Software. The modified JSON format is a breaking change in Spine 3.8 beta.

I made pretty much the changes you suggested, but making sure that the previous format is still supported. I'll make a release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants