Switching keyed attachments at runtime
Hi, so we're trying to use Spine to create a few character animations, but we're running into a bit of a hitch and wanted to see if anyone has any suggestions for what we're trying to do. We need to switch out parts of the character during an animation. For instance, an idle would play, but the character would need to be able to switch out heads or other body parts. Skins would be a sensible option, except that skins is a kind of all-or-nothing deal, so we can't have the character wearing Head A with Body B and Feet D. So what I've done so far is create slots with each possible body part that would change added as an attachment to the slot, so Slot Head would include attachments for Head A, Head B, Head C, and so on. Now the other issue is that part of the animation includes switching out art pieces. For instance, Head A has four images (say, for instance, the head turning around) and those attachments are keyed within the animation. Head B, C, and so on would also have four images, but only Head A's are keyed. How do we use that animation but make it possible to call other attachments at runtime? Do I have to key each one for the animations to work as intended?
The way you reuse animations with skeletons that have different attachments is with skins. If you have 4 head images, you'll have 1 head slot and 4 skin placeholders. In each skin you would have a region attachment for each of these 4 skin placeholders. Now you can animate by showing any of these 4 skin placeholders and you don't actually care what region attachment is show
which actual attachment is used comes from the skin.
You can create a skin at runtime and populate it as needed. You could even use one or more skins you created in Spine to populate it. Example here:
http://esotericsoftware.com/spine-using ... ting-skins