SpineDrawableBatch
Last updated
Last updated
The SpineDrawableBatch class is responsible for drawing Spine in your FlatRedBall game. If you have used Tiled in your FlatRedBall projects, you can think of the SpineDrawableBatch as being similar to a Tiled Layer. In other words, the SpineDrawableBatch has the following characteristics:
It can be positioned explicitly, although this is typically done through attachments in generated code
It has a Z value which controls its sorting
It produces a new render break (this may change in the future)
By contrast, normally Tiled maps are added to Screens; however, SpineDrawableBatches are typically added to Entities.
Spine files are needed to draw a SpineDrawableBatch. Conceptually you can think of these files similar to how you might think of a .achx file - it needs to be loaded as part of an entity or screen before it can be used to display any graphics.
To add a SpineDrawableBatch to an entity:
Create an entity that will contain the SpineDrawableBatch. This example uses an Entity called Soldier
Drag+drop the texture file (.png) used by the Spine atlas into the Entity's files
Drag+drop an Atlas file (.atlas) into the Entity's files
Drag+drop a Spine skeleton file (.json) into the Entity's files
Select the Skeleton entry in FlatRedBall, click on the Spine tab, and change the Atlas property the desired Atlas file. It should appear in the dropdown.
Important: At the time of this writing, the three files must be loaded in the proper order. The order is:
Texture file (.png)
Atlas (.atlas)
Skeleton (.json)
You can re-order the files by holding down the ALT key on the keyboard and pressing the up and down keys.
This requirement may go away in the future as the Spine plugin gets better at tracking dependencies.
Note that the texture file (.png) is loaded when the atlas is created and ultimately uses a FlatRedBall content manager. This means that if your png is already loaded (such as by being in Global Content Files), then you do not need to also have the png in your entity. This is especially useful if your atlas references a shared sprite sheet which is used by other screens and entities.
Now the Spine files have been added to the entity, we need to add them as an object. By adding an object we can control properties such as position (offset) and scale. Also, each individual object can be independently animated. To add and attach the SpineDrawableBatch:
Drag+drop the skeleton file from Files onto Objects
Change the Source name to Entire File (SpineDrawableBatch)
Enter a name such as SpineDrawableBatch
Click OK
You should now have all three files in your Entity as well as a SpineDrawableBatch in the Objects folder.
To see the entity instance in-game, drag+drop the entity onto a Screen, such as GameScreen. Run the game and the Spine Drawable Batch should appear.