Legacy GM Quick question on Spine and sprite_add

S

Suppercut

Guest
Simply put, is it possible to use sprite_add or sprite_replace with a Spine2D json?

I'm asking because I'd like to support multiple LoDs (level of detail) for the character models in my games, so I can target both decent gaming PCs and maybe one or two mobile platforms (mostly the GPD Win that I've been trying to use to bugfix on the go, but if I could get this game running on an Android using XB1 controllers that would be a sick bonus). Of course, GM:S1.4 doesn't like supporting Spine 2D's built-in feature of multiple LoDs (in the atlas settings), so the only logical replacement would be to make it import the alternate files at game launch, but I'm not sure if GM:S supports that.
 

rIKmAN

Member
Simply put, is it possible to use sprite_add or sprite_replace with a Spine2D json?
You should be able to use sprite_add() to add the relevant sprites and then use skeleton_attachment_set() to set them into the relevant slot on the skeleton. Same with sprites already added via the IDE - they both end up with a sprite_index.

skeleton_attachment_set() manual entry:
A skeletal animation sprite may have other images added as attachments, with these images being added to a named slot (the name is given when you create the attachment slot in your animation program) and they will be drawn along with the animation of the current sprite. With this function you can set an attachment to a given slot, where you are required to give the names (as strings) of the slot and the attachment. These names are defined by the animation program used, or (in the case of the attachment) when you call skeleton_attachment_create.

Note that you can also pass a sprite_index in as the attachment, and that sprite will be used, or you can use -1 to remove the attachment from the slot.
 
S

Suppercut

Guest
You should be able to use sprite_add() to add the relevant sprites and then use skeleton_attachment_set() to set them into the relevant slot on the skeleton. Same with sprites already added via the IDE - they both end up with a sprite_index.

skeleton_attachment_set() manual entry:
How would this work in the context of what I'm trying to do? What this sounds like is suggesting I make a separate sprite for every bone in my animation, and replacing every bone with that sprite. The problem is, how would it know what the new origin would be if I were to replace each bone with a smaller or larger image? Would I then have to reset the base scaling of each bone manually?
 

rIKmAN

Member
How would this work in the context of what I'm trying to do? What this sounds like is suggesting I make a separate sprite for every bone in my animation, and replacing every bone with that sprite. The problem is, how would it know what the new origin would be if I were to replace each bone with a smaller or larger image? Would I then have to reset the base scaling of each bone manually?
You aren't replacing bones, you are just changing the images attached to the slots (the same as attaching images to slots inside Spine).
The skeleton holds the slot data, whatever image is attached to it will be positioned as per the slot data and animation in Spine.

As for different sized images, Spine supports scaling texture atlases for this exact thing, but I'm not sure if GMS supports it as I've never tried to use it. Probably not - but try it and report back what happens?

If not, as a workaround you might end up having to create different skeletons with the different sprites and loading that in depending on the target device using sprite_add(). (You can load .json files using sprite_add() as I've done this myself in GMS2, not sure about 1.4).
 
Top