• Runtimes
  • [Libgdx] how to choose the slot's skin-placeholder?

  • Изменено
Related Discussions
...

I have a slot "sandir_flower" that has two skin-placeholders. I need to switch between the skin-placeholders at runtime depending on whether the game is on Easy or Hard difficulty.

I figured the skin-placeholders would act as as though they are attachments and that I could select it by doing this:

skeleton.setAttachment("sandir_flower", "flower_sandir_easy");

But that results in this error:

Attachment not found: flower_sandir_easy, for slot: sandir_flower

How can I select which skin-placeholder to display at runtime? Thanks!


note: I also tried using skeleton.setAttachment("sandir_flower", "regular/blessing_flowers/high_def/Globe Mallow"); which also results in 'attachment not found'

This is correct:

skeleton.setAttachment("sandir_flower", "flower_sandir_easy");

Have you set a skin that has an attachment for the "flower_sandir_easy" placeholder? You can look in your JSON data to be sure it's there.

Nate написал

This is correct:

skeleton.setAttachment("sandir_flower", "flower_sandir_easy");

Have you set a skin that has an attachment for the "flower_sandir_easy" placeholder? You can look in your JSON data to be sure it's there.

Thanks Nate! The initial skin I was applying skeleton.setAttachment("sandir_flower", "flower_sandir_easy"); to did NOT have an attachment for "flower_sandir_easy". Was able to fix the issue with the new knowledge. :yes: :yes: