Setup
To use Spine in your project, you must do the following high level steps. Each step will be explained in detail below:
Link your game project against FlatRedBall Source
Link your game project against the Spine
Load the Spine shader (.fx) file
You can use Spine purely in code, or you can use Spine in the FlatRedBall Editor by adding the Spine plugin. The FlatRedBall Editor plugin enables adding Spine files (skeleton and atlas) to your FlatRedBall project. The plugin generates code for loading these files.
To use the Spine plugin, you must also install the SpinePlugin .plug file.
Linking to Source
The first step is to link your FlatRedBall project to source. To link your game to FlatRedBall Source, see the Building FlatRedBall From Source page.
Once you have linked your game to FlatRedBall Source, you need to link your game to FlatRedBall.Spine.MonoGame.DesktopGL. As of January 15, 2024, MonoGame DesktopGL is the only platform that supports FlatRedBall.Spine. New platforms will likely be added over time. If you are planning on targeting a new platform, make a request on Discord.
To add FlatRedBall.Spine to your project:
Clone the repository for FlatRedBall.Spine https://github.com/flatredball/FlatRedBall.Spine
Open your project in Visual Studio
Right-click on your Solution in the Solution Explorer
Select Add -> Existing Project...
Navigate to the folder where you cloned FlatRedBall.Spine and select
<FlatRedBall.Spine Root>/Source/FlatRedBall.Spine.MonoGame.DesktopGL.csproj
Expand your game project and right-click on Dependencies, then select Add Project Reference...
Check FlatRedBall.Spine.MonoGame.DesktopGL to link this library in your game project's dependencies, then click OK.
Your project should now link to FlatRedBall.Spine.MonoGame.DesktopGL.csproj.
After adding the reference, be sure to save your project. You can do this by selecting the File->Save All option in Visual Studio, or by pressing CTRL+SHIFT+S in Visual Studio. Alternatively, you can run your game which saves the .csproj.
This step is important because the .csproj modifications must be saved so the FRB Editor can re-load the .csproj. Forgetting this step can result in the library not being linked.
Adding FlatRedBall.Spine Plugin
Although it is not necessary, using the FlatRedBall.Spine plugin is recommended as it can reduce the amount of code necessary to work with Spine. To install the FlatRedBall.Spine plugin:
Download the SpinePlugin.plug file from the Releases page https://github.com/flatredball/FlatRedBall.Spine/releases
Select Plugin->Install Plugin in FlatRedBall
We recommend selecting "For User" so the plugin is installed globally, but you can do it for project if you do not want other projects to use this plugin.
Use the ... button to locate and select the SpinePlugin.plug file, then click OK
Restart the FlatRedBall Editor
Once you have restarted FlatRedBall, you should see Spine listed in the installed plugin. Select Plugins -> Manage Plugins, and scroll down to make sure the plugin has installed.
Alternative - Adding FlatRedBall.Spine Plugin from Source
Alternatively you can clone the Spine plugin if you prefer to build from source and diagnose problems. To do this:
Clone the FlatRedBall.Spine repository https://github.com/flatredball/FlatRedBall.Spine. If you clone both FRB and this repository to the same root Github location, then the file links will work correctly
Open SpinePlugin/SpinePlugin.sln
Build->Rebuild the plugin
The latest plugin .dll will be built and also copied over to the Glue output folder.
Loading the Spine Shader
The SpineShader is required to render Spine. To load the Spine Shader:
Download SpineEffect.fx file from the Releases page https://github.com/flatredball/FlatRedBall.Spine/releases
Add the SpineEffect.fx file to GlobalContent by drag+dropping the file into your Global Content Files folder in FlatRedBall
Open Game1.cs and add the following code in Initialize after
GeneratedInitialize();
:
Troubleshooting
The type or namespace name 'Spine' does not exist in the namespace 'FlatRedBall' (are you missing an assembly reference?)
If you are missing a Spine reference in FlatRedBall, then you may not have saved the .csproj after adding a reference to the Spine project. To fix this:
Right-click on your game project's Dependencies and select Add Project Reference
Check if the FlatRedBall.Spine.MonoGame.DesktopGL (or appropriate project for your target platform) is selected.
If not, check the project, click ok, then save you project. At this point you can build/run your game and this also saves your .csproj.
Last updated