Top Related Projects
Defold is a completely free to use game engine for development of desktop, mobile and web games.
Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
Desktop/Android/HTML5/iOS Java game development framework
Godot Engine – Multi-platform 2D and 3D game engine
Quick Overview
Spine-runtimes is a collection of runtime libraries for Spine, a 2D skeletal animation tool. These runtimes allow developers to integrate Spine animations into various game engines and frameworks, providing efficient and flexible 2D character animation capabilities across multiple platforms.
Pros
- Supports a wide range of game engines and frameworks (Unity, Unreal, Godot, LibGDX, etc.)
- Offers optimized performance for 2D skeletal animations
- Provides extensive documentation and examples for each runtime
- Regular updates and active community support
Cons
- Learning curve can be steep for beginners
- Requires the Spine editor (separate purchase) to create animations
- Some advanced features are only available in higher-tier licenses
- May require additional setup and integration work depending on the target platform
Code Examples
- Loading a Spine skeleton (using spine-ts runtime):
const atlas = new TextureAtlas(atlasData);
const atlasLoader = new AtlasAttachmentLoader(atlas);
const skeletonJson = new SkeletonJson(atlasLoader);
const skeletonData = skeletonJson.readSkeletonData(skeletonData);
const skeleton = new Skeleton(skeletonData);
const animationStateData = new AnimationStateData(skeletonData);
const animationState = new AnimationState(animationStateData);
- Playing an animation (using spine-ts runtime):
animationState.setAnimation(0, "run", true);
animationState.addAnimation(0, "jump", false, 2);
- Rendering a skeleton (using spine-ts runtime with Canvas):
function render() {
canvas.clear();
skeleton.x = 200;
skeleton.y = 400;
skeleton.updateWorldTransform();
skeletonRenderer.draw(skeleton);
requestAnimationFrame(render);
}
Getting Started
To get started with Spine runtimes:
- Choose the appropriate runtime for your target platform/engine.
- Download the runtime from the GitHub repository.
- Include the runtime in your project.
- Load your Spine skeleton and atlas data.
- Create a skeleton instance and animation state.
- Update and render the skeleton in your game loop.
Example setup for spine-ts with Canvas:
import { Atlas, AtlasAttachmentLoader, Skeleton, SkeletonJson, AnimationState, AnimationStateData, SkeletonRenderer } from '@esotericsoftware/spine-canvas';
// Load atlas and skeleton data
const atlas = new Atlas(atlasData);
const skeletonJson = new SkeletonJson(new AtlasAttachmentLoader(atlas));
const skeletonData = skeletonJson.readSkeletonData(skeletonJsonData);
// Create skeleton and animation state
const skeleton = new Skeleton(skeletonData);
const animationState = new AnimationState(new AnimationStateData(skeletonData));
// Set up renderer
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const renderer = new SkeletonRenderer(context);
// Game loop
function update(delta: number) {
animationState.update(delta);
animationState.apply(skeleton);
skeleton.updateWorldTransform();
renderer.draw(skeleton);
requestAnimationFrame(update);
}
update(0);
Competitor Comparisons
Defold is a completely free to use game engine for development of desktop, mobile and web games.
Pros of Defold
- Complete game engine with built-in tools for 2D and 3D game development
- Cross-platform support for multiple platforms, including mobile and web
- Active community and extensive documentation
Cons of Defold
- Steeper learning curve for developers new to the Defold ecosystem
- Less flexibility compared to Spine runtimes, which can be integrated into various engines
Code Comparison
Defold (Lua):
function init(self)
msg.post(".", "acquire_input_focus")
self.position = vmath.vector3()
end
function update(self, dt)
self.position = self.position + vmath.vector3(1, 0, 0) * dt
go.set_position(self.position)
end
Spine runtimes (JavaScript):
let skeleton = new spine.Skeleton(skeletonData);
let animationState = new spine.AnimationState(animationStateData);
function update(delta) {
animationState.update(delta);
animationState.apply(skeleton);
skeleton.updateWorldTransform();
}
The code snippets demonstrate basic setup and update functions for each project. Defold uses Lua and provides a more game-engine-centric approach, while Spine runtimes (shown in JavaScript) focus specifically on skeletal animation functionality that can be integrated into various environments.
Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
Pros of cocos2d-x
- More comprehensive game development framework with a wider range of features
- Supports multiple platforms including mobile, desktop, and web
- Large and active community with extensive documentation and resources
Cons of cocos2d-x
- Steeper learning curve due to its extensive feature set
- Larger codebase and potentially higher resource usage
- Less specialized for 2D skeletal animation compared to spine-runtimes
Code Comparison
spine-runtimes (C++):
spSkeleton* skeleton = spSkeleton_create(skeletonData);
spAnimationState* state = spAnimationState_create(spAnimationStateData_create(skeletonData));
spAnimationState_setAnimationByName(state, 0, "walk", true);
cocos2d-x (C++):
auto sprite = Sprite::create("character.png");
auto animation = Animation::create();
animation->addSpriteFrameWithFile("walk1.png");
animation->addSpriteFrameWithFile("walk2.png");
sprite->runAction(RepeatForever::create(Animate::create(animation)));
While spine-runtimes focuses on skeletal animation with a more specialized API, cocos2d-x provides a broader set of tools for game development, including sprite-based animation. The code examples illustrate the different approaches to animation in each framework.
Desktop/Android/HTML5/iOS Java game development framework
Pros of libgdx
- More comprehensive game development framework with a wider range of features
- Supports multiple platforms including desktop, mobile, and web
- Large and active community with extensive documentation and tutorials
Cons of libgdx
- Steeper learning curve due to its broader scope
- Potentially heavier and more resource-intensive for simple 2D projects
- Less specialized for skeletal animation compared to Spine runtimes
Code Comparison
Spine runtimes (loading a skeleton):
SkeletonBinary binary = new SkeletonBinary(atlas);
SkeletonData skeletonData = binary.readSkeletonData(Gdx.files.internal("spineboy.skel"));
Skeleton skeleton = new Skeleton(skeletonData);
libgdx (loading a texture):
Texture texture = new Texture(Gdx.files.internal("image.png"));
Sprite sprite = new Sprite(texture);
While both libraries can be used for game development, Spine runtimes focuses specifically on skeletal animation, providing specialized tools for that purpose. libgdx, on the other hand, offers a more general-purpose game development framework with a broader set of features. The choice between the two depends on the specific needs of your project, with Spine runtimes being more suitable for projects heavily focused on skeletal animation, and libgdx being a better choice for more diverse game development requirements.
Godot Engine – Multi-platform 2D and 3D game engine
Pros of Godot
- Open-source and free game engine with a large community
- Supports multiple programming languages (GDScript, C#, C++)
- Comprehensive built-in tools for 2D and 3D game development
Cons of Godot
- Steeper learning curve for beginners compared to Spine
- Less specialized for 2D skeletal animation than Spine
- Larger project size and resource requirements
Code Comparison
Godot (GDScript):
var skeleton = Skeleton2D.new()
var bone = Bone2D.new()
skeleton.add_child(bone)
bone.set_rest(Transform2D(0, Vector2(100, 0)))
Spine (Java):
Skeleton skeleton = new Skeleton(skeletonData);
Bone bone = skeleton.findBone("bone1");
bone.setPosition(100, 0);
Both examples demonstrate basic skeleton and bone manipulation, but Godot's approach is more integrated with its scene system, while Spine focuses on direct skeletal animation control.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Spine Runtimes
This GitHub project hosts the Spine Runtimes which are needed to use Spine 2D skeletal animation data with various game toolkits.
Licensing
You are welcome to evaluate the Spine Runtimes and the examples we provide in this repository free of charge.
You can integrate the Spine Runtimes into your software free of charge, but users of your software must have their own Spine license. Please make your users aware of this requirement! This option is often chosen by those making development tools, such as an SDK, game toolkit, or software library.
In order to distribute your software containing the Spine Runtimes to others that don't have a Spine license, you need a Spine license at the time of integration. Then you can distribute your software containing the Spine Runtimes however you like, provided others don't modify it or use it to create new software. If others want to do that, they'll need their own Spine license.
For the official legal terms governing the Spine Runtimes, please read the Spine Runtimes License Agreement and Section 2 of the Spine Editor License Agreement.
Documentation
See the Spine Runtimes Guide for detailed information about using the Spine Runtimes. The Spine documentation page provides further information about tools and data formats. For runtime specific documentation, refer to the README.md
file in each runtime directory.
Bugs, enhancements, and tasks
Review our backlog of bugs, enhancements, and tasks in the spine-runtimes and spine-editor issue trackers. Our roadmap provides a more convenient view of the same issue tracker information.
Versioning
The default branch on GitHub is stable and works with data exported from the latest, non-beta version of the Spine editor. New development is done in an X.X-beta
branch, which may be a work in progress. Important changes to the runtimes can be reviewed in the CHANGELOG.md file. Occasionally the Spine Runtimes are tagged with the specific Spine editor version they work with.
It is highly suggested to freeze the Spine editor version to match the Spine Runtimes source being used and to update them in lock step. See the Spine Runtimes Guide for more information.
Contributing
In order to merge your contributions, we need a signed contributor license agreement (CLA) from you. You can send a copy of the CLA to contact@esotericsoftware.com.
When possible, it is best to base your contributions on the current beta branch (X.X-beta
). Please be sure to follow the style and formatting you find in the respective runtime code to which you are contributing.
Top Related Projects
Defold is a completely free to use game engine for development of desktop, mobile and web games.
Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
Desktop/Android/HTML5/iOS Java game development framework
Godot Engine – Multi-platform 2D and 3D game engine
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot