Spine: Using Multiple Texture Pages

With the 2.2.2 update to GameMaker Studio 2, general Spine support was improved and as part of that you can now import Spine sprites with multiple texture pages. In general, all this means for you is that when you import a Spine JSON file that has 2 or more texture pages, then GameMaker Studio 2 will automatically detect this and add all of them as part of the sprite data, and then you can switch skins as normal in your project, even if the skins are on different texture pages.

NOTE: Spine texture pages are specific to that Spine sprite and pages cannot be shared between different sprites or any other assets in a GameMaker Studio 2 project.

However, it is often the case that you will want your texture pages ordered in a specific way so that the images are stored in a logical order and don't create too many texture swaps with one sprite having to swap between two texture pages to be drawn correctly. An example we'll use in the images below is the Spine "Goblin". It has a male skin, a female skin and attachments, and you'd want each of these skins to have their own texture page.

To correctly create texture pages in this way, you first need to have your base images stored with a folder structure that permits them to be interpreted as different texture pages. In the case of our Spine goblin, we'd have something like this:


The next thing to do is open Spine and export the sprite that want to use these images for the texture (we'll pack them in a moment). When exporting, it is important to note that we only want the JSON file, and not any textures, so make sure that the Pack option is unchecked:


Take note of the export location, as we¡ll be directing the texture packer to that location now. To open the Texture Packer, go to the Spine menu (click the top left in Spine) and select Texture Packer. This will open the following window:


The Input Folder should point to where you have your base images saved (as explained at the top of this article), while the Output Folder should point to the location of the exported JSON file. You can now click on the Pack button to create your texture pages and atlas file (note that you can click the Settings button first if you want to set the texture page size, or any other things related to the final texture page output).

IMPORTANT! Make sure that the atlas name you give is the same as the name you gave the JSON file on export.

If all has gone correctly, you should now have something like this in the folder with the JSON:


You can now select the JSON file in the GameMaker Studio 2 sprite editor to import the sprite and then continue to work as normal.

Have more questions? Submit a request


Article is closed for comments.