Spine hide/show slot/attachment

Spine hide/show slot/attachment
0.0 0


I’m trying to hide or show particular slot or attachment in spine model.

I’ve only found one working solution:

spSkeleton_setAttachment(anim->getSkeleton(), "some_attachment_name", 0);

But then I don’t know how to show attachment back (and check whether is visible).

I’ve a slot using this:
auto slotData = spSkeletonData_findSlot(anim->getState()->data->skeletonData, "some_slot_name");

but then changing a (alpha) to 0 doesn’t do anything.


anyone, please :smiley: ?


spSkeleton_setAttachment(anim->getSkeleton(), “some_attachment_name”, “some_attachment_image_name”);


spSkeleton_getAttachmentForSlotName this returns 0 if there is no attachment


Ok, maybe I don’t understand something so I’ll just show you full example. Here’s how it looks in spine:

I don’t know how can I find attachment name. The slot I want to hide is named “balon_r”.

Here’s my code:

auto attachment = spSkeleton_getAttachmentForSlotName(anim->getSkeleton(), "balon_r", "balon_r?????"); //what's the attachment name?
if(attachment == 0){
      spSkeleton_setAttachment(anim->getSkeleton(), "balon_r", "balon_r.png????"); //how can I find image name, it is in atlas, should it be the same name as is shown in spine?
      spSkeleton_setAttachment(anim->getSkeleton(), "balon_r", 0);

I tried “balon_r” and “balon”.

First of all getAttachmentForSlotName always return null, because I don’t know what is the attachment name, only slot name.
Anyway this alone:

spSkeleton_setAttachment(anim->getSkeleton(), "balon_r", 0);


  spSkeleton_setAttachment(anim->getSkeleton(), "balon_r", "balon_r");

make sure you are using the right skin when changing the attachments


im using it for all my guns like this

else if (PowerupType == PowerUpLaser)
FileHandler::getInstance()->PowerUp = PowerUpLaser;
spSkeleton_setAttachment(Player::getInstance()->getSkeleton(), “laserGun”, “laserGun”);

    this->schedule(schedule_selector(PlayerPowerUp::laserLogic), 0);
    str = "KER-BLASTER";


the round bullet in spine is the attachment slot… the green bullet/icon is the attachment name. You have to set the right skin in order to make the attachment work


I do have the right skin and it spSkeleton_getAttachmentForSlotName gives me always null.


made a test case. this doesn’t work on skins… i’ll try and find a solution


@piotrros you can change the opacity for now

spSlot *slot = spSkeleton_findSlot(anim->getSkeleton(), “balon_r”);
slot->a = 0;


Wow, I just wanted to say I’ve already tried that, but looks like it’s working:

I was getting slot like this:

auto slotData = spSkeletonData_findSlot(anim->getState()->data->skeletonData, "balon_r");

but you suggested this:

spSlot *slot = spSkeleton_findSlot(anim->getSkeleton(), "balon_r");

and it worked, thanks a lot!!