• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Accessing skeletal sprites' json files

Hay, I was asked from Twitter to go here

Concerning: GameMaker:Studio 2 + Spine

Question: Is it possible to somehow access the skeletal sprites' json files through code?

Elaboration: As some people may know, I use Spine together with GameMaker a lot. In the past when I have needed to access the json of a sprite, then I have added the json file to the included files. I did this for my Spine Events extension. But this is of course just a workaround. It is not ideal to have each json file in the project two times. What I would like to know, is whether I can somehow access the json files from the sprites themselves, so that I do not need to upload the json files in the included files as well.

Regards,
Simon
 

gnysek

Member
From GMS sprite? You can't access. You can use some DLL to read those files from disk, but as soon as you move directory on your PC or run game on another PC it will stop to work.
 
From GMS sprite? You can't access. You can use some DLL to read those files from disk, but as soon as you move directory on your PC or run game on another PC it will stop to work.
Hmm, thought so, too bad. It would open up for sooo many possibilities! But it is quite a waste of resources to need to load in the json an extra time (and annoying to need to update it every time the animations are updated), but at least json files are not huge :)
 

gnysek

Member
Yes, that's true, it should be possible to access some of loaded metadatas of GMS game, I've talked about this several times (for example room settings - not all are readable).
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
From what I've seen, Spine files are converted into some binary format during compilation (or encoded), so the data is there but how to read it is a different question.
 
From what I've seen, Spine files are converted into some binary format during compilation (or encoded), so the data is there but how to read it is a different question.
I see, that complicates matters.. But nice to know (I mean, of course the data is there in some way or form, but nice to know that it is not just a json any more).
It makes sense that the data is converted
 

rIKmAN

Member
I'm probably misunderstanding the question here, but you can load json files as external files (not loading them in the IDE) by loading them as you would with any normal image sprite, but loading the .json instead.

It worked fine, as this is what I did when writing some tools for an artist to work with Spine assets he was creating without having to send them to me and wait to see them running in-engine.
 
I'm probably misunderstanding the question here, but you can load json files as external files (not loading them in the IDE) by loading them as you would with any normal image sprite, but loading the .json instead.

It worked fine, as this is what I did when writing some tools for an artist to work with Spine assets he was creating without having to send them to me and wait to see them running in-engine.
Yeah, I mean, that could be a workaround, but then all the sprites needs to be external, which is not ideal to me. But it is nice to know, that you can load in json files like that. I did not know that :D Just to be sure what you mean: So I would be able to use sprite_add in my code to load in the json, and I would get a functional, skeletal sprite? :) (I mean, assuming all the right files are lying with the json) Or how would I load them in?

To clarify: What I really need (or, would like to be able to) is to read data from the jsons of sprites loaded into the IDE.
But that seems to be problematic.
 

rIKmAN

Member
Yeah, I mean, that could be a workaround, but then all the sprites needs to be external, which is not ideal to me. But it is nice to know, that you can load in json files like that. I did not know that :D Just to be sure what you mean: So I would be able to use sprite_add in my code to load in the json, and I would get a functional, skeletal sprite? :) (I mean, assuming all the right files are lying with the json) Or how would I load them in?

To clarify: What I really need (or, would like to be able to) is to read data from the jsons of sprites loaded into the IDE.
But that seems to be problematic.
Yeah, using sprite_add() works fine when loading the .json file, there are a couple of small differences functionality-wise than when using IDE loaded json but nothing major.

I used this method to write a tool for an artist so he could export from Spine, then the tool would load these in using sprite_add() and he could test out the animations he'd been working on "in-game" so to speak (link together animations, change playback speed, loop, zoom etc) and not have to send the json to me and wait for me to import them and send them back.

I'm not sure why you would want to access the json after it's been loaded into the IDE, what are you trying to do?
 
Nice :)
I'm not sure why you would want to access the json after it's been loaded into the IDE, what are you trying to do?
Well, nothing too specific - it is just to achieve more control in terms of layered animations and animation manipulation ^^ Like, for a simple case, I would like to stack animations, but chose which frame of the secondary animation/track to display. Or mix two animations depending on speed (mixing walking/running or running/sprinting seamlessly, for example) :)
But it was just ideas, thoughts - things I'd like to try out :) And at least they may work with external files, so that's nice enough :p
 

rIKmAN

Member
Nice :)

Well, nothing too specific - it is just to achieve more control in terms of layered animations and animation manipulation ^^ Like, for a simple case, I would like to stack animations, but chose which frame of the secondary animation/track to display. Or mix two animations depending on speed (mixing walking/running or running/sprinting seamlessly, for example) :)
But it was just ideas, thoughts - things I'd like to try out :) And at least they may work with external files, so that's nice enough :p
Ah I see, well hopefully when YYG ever get around to either updating the runtimes or breaking out Spine into an extension as Russell has mentioned a few times then this functionality can be added as standard just like the official runtimes.

The current Spine support in GMS is as basic as it can be whilst still allowing them to advertise that it "supports Spine", it's a real shame.

Update us if you get anywhere with it or find anything interesting!
 
Top