Tutorial

Page 3 of 10

Adding A spine Sprite

If you run the test game that came along with this tutorial, you will see that we have a simple scrolling background and a main sprite that appears to be "floating" over the surface of the road. We are going to use a Spine skeletal animation sprite to make this main sprite walk and jump along the road, and we are also going to have it change skins and use different attachments.

However, before we get to those things, we first need to load the sprite into the IDE...

Loading JSON Files

When you export a skeletal animation sprite from Spine as JSON, you will actually be creating three separate files. The base JSON which contains all the bone data and animations, the .atlas file which has the data about how the textures are packed, and a PNG file which contains the texture atlas itself. GameMaker: Studio requires all three files to create your Spine sprite, so they should all be in the same folder when importing.


The way to import them into the GameMaker: Studio is almost identical to that for adding a normal bitmap image - you need to create a new sprite which will bring up the standard Load Sprite dialogue, and then make sure that you have selected *.json from the file filter at the bottom before browsing to where you have saved the Spine files and selecting the one you wish to import.

So, let's do that now! Create a new sprite and call it "spr_Player". Click on the "Load Sprite" button and browse to the folder "Skeletal Animation Assets", then select the JSON file that you will find there and click "Open" to import it into our new sprite.


Once you have imported the animation, you can set the collision properties, but note that you are limited here to simply using precise collisions or bounding box collisions, and that the collision data for a skeletal animation is explicitly taken from the data provided (meaning that you should set this correctly in Spine before exporting for use). GameMaker: Studio does not generate any collision mask if the data is missing from the imported file, meaning you simply won't get working collisions if the masks are not set correctly in Spine. Also, unlike bitmap sprites, the imported skeletal animation sprite cannot be modified in the editor in any way, meaning any changes that need to be made should be done in Spine and then re-imported into your game.
NOTE: Due to the complexity of skeletal animations, the preview image shown in the sprite editor is not intended to accurately represent your animation, but rather give you a simple image that represents the animation for visualising in the room editor.
You should now open the object "oPlayer" and assign it this new sprite instead of the current bitmap version. What happens if you run the game now? Well, nothing! This is because we haven't given the sprite an animation to run yet, so let's look at getting it moving next.



© Copyright YoYo Games Ltd. 2014 All Rights Reserved