Yes, skeletons can definitely share an atlas! Normally you would design your skeletons with the individual image files and then pack a single atlas that contains the texture regions for both skeletons. You don't want to juggle texture atlas images or hand edit your atlas file.
I suggest packing your atlas separately from exporting your skeleton data. See:
Korean: 텍스처 패킹 - Spine 사용자 가이드: 텍스처 패커를 별도로 실행
English: Texture packing - Spine User Guide: Running the texture packer separately
If both your skeletons are in the same project, then you could instead pack the atlas as part of data export. However, I prefer packing separately, as it is cleaner and faster when the image files haven't changed.
When you load the skeleton data, load the atlas once, create a loader, and load both skeletons with it:
Korean: Loading Skeleton Data - Spine Runtimes Guide: 스켈레톤 데이터 로딩
English: Loading Skeleton Data - Spine Runtimes Guide: Loading Skeleton Data
Example code:
AtlasAttachmentLoader attachmentLoader = new AtlasAttachmentLoader(atlas);
SkeletonJson json = new SkeletonJson(attachmentLoader);
SkeletonData skeletonData1 = json.readSkeletonData("skeleton1.json");
SkeletonData skeletonData2 = json.readSkeletonData("skeleton2.json");
The attachment name or path is used to find the region in the atlas. For example, an attachment named head
would find the atlas region named head
. If both skeletons use the same atlas and have an attachment named head
, they'll both use the same atlas region.
You may want to organize your image files so you can set the images folder for your Spine projects to the same folder. For example, if your skeletons have the same "head" image but different "armor" images, your files might be:
images/head.png
images/skeleton1/armor.png
images/skeleton2/armor.png
You'd set both your skeleton's images folder to images
. You may need to rename your attachments (or set a path) after moving your image files around. For that see Find and Replace:
Korean: 트리 뷰 - Spine 사용자 가이드: 찾기 및 바꾸기
English: Tree view - Spine User Guide: Find and replace
For example, your attachment name for skeleton1 would be skeleton1/armor.png
and for skeleton2 would be skeleton2/armor.png
. If you don't want to see the skeleton1/
and skeleton2/
prefixes in Spine, you can hide it in the tree:
Korean: 트리 뷰 - Spine 사용자 가이드: 스켈레톤 이름 숨기기
English: Tree view - Spine User Guide: Hide skeleton names