### Install and Run Example Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-threejs/example/react-three-fiber/README.md Install project dependencies and start the development server. Open the provided Vite URL to view the animated raptor. ```sh npm install npm run dev ``` -------------------------------- ### Build Example on Linux Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-sfml/README.md Install dependencies, clone the repository, and build the example using the provided build script. Then, run the compiled example. ```bash sudo apt-get install cmake ninja-build libsfml-dev # Ubuntu/Debian # or equivalent for your distribution git clone https://github.com/esotericsoftware/spine-runtimes cd spine-runtimes/spine-sfml ./build.sh ./build/debug/spine-sfml-example ``` -------------------------------- ### Build Example on macOS Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-sfml/README.md Install Xcode and Homebrew, then install CMake and Ninja. Clone the repository, build the example using the script, and then run it. ```bash brew install cmake ninja git clone https://github.com/esotericsoftware/spine-runtimes cd spine-runtimes/spine-sfml ./build.sh ./build/debug/spine-sfml-example ``` -------------------------------- ### Initiate Application Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-threejs/example/index.html Calls the init function to start the application setup. ```javascript init(); ``` -------------------------------- ### Build and run C example on Linux Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-sdl/README.md Build the spine-sdl C example using the provided build script and run the executable. Ensure CMake and Ninja are installed. ```bash cd spine-runtimes/spine-sdl ./build.sh ./build/debug/spine-sdl-c-example ``` -------------------------------- ### Run Spine-Haxe Examples Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-haxe/README.md Compile and run the provided examples to see spine-haxe in action. This command starts a local server to view the examples in a browser. ```bash lime test html5 ``` -------------------------------- ### Build and run C++ example on Linux Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-sdl/README.md Build the spine-sdl C++ example using the provided build script and run the executable. Ensure CMake and Ninja are installed. ```bash cd spine-runtimes/spine-sdl ./build.sh ./build/debug/spine-sdl-cpp-example ``` -------------------------------- ### Install Dependencies and Run Development Server Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/README.md Installs project dependencies and starts a local web server for development. The server automatically reloads on code changes and keeps build tools in watch mode. ```bash git clone https://github.com/esotericsoftware/spine-runtimes cd spine-runtimes/spine-ts npm install npm run dev ``` -------------------------------- ### Run Spine-TS Examples Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/README.md Compile and run the example applications for spine-ts modules. This command should be executed from the 'spine-runtimes/spine-ts' directory after installing Node.js. ```bash npm run dev ``` -------------------------------- ### Example Executable Configuration Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-sfml/CMakeLists.txt Configures an example executable if BUILD_EXAMPLES is enabled. It links the example to the spine-sfml library and copies necessary data files. ```cmake # Example if(BUILD_EXAMPLES) add_executable(spine-sfml-example example/main.cpp) target_link_libraries(spine-sfml-example spine-sfml) # Copy data to build directory add_custom_command(TARGET spine-sfml-example PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/data $/data) endif() ``` -------------------------------- ### Build and Run spine-glfw Examples on Linux/macOS Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-glfw/README.md Build the project using the provided build script and then run the C or C++ examples. ```bash cd spine-runtimes/spine-glfw ./build.sh ./build/debug/spine-glfw-example-c # Run C example ./build/debug/spine-glfw-example # Run C++ example ``` -------------------------------- ### Setting an Empty Animation (Setup Pose) Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-c/docs.md Details how to transition to the skeleton's setup pose using empty animations. ```APIDOC ## spAnimationState_setEmptyAnimation & spAnimationState_addEmptyAnimation ### Description These methods allow transitioning to the skeleton's setup pose. `setEmptyAnimation` clears the current track and crossfades to the setup pose. `addEmptyAnimation` enqueues a crossfade to the setup pose as part of the animation sequence on a track. ### Methods - `spAnimationState_setEmptyAnimation(animationState, trackIndex, mixDuration, delay)` - `spAnimationState_addEmptyAnimation(animationState, trackIndex, mixDuration)` ### Parameters - **animationState** (*spAnimationState*) - The animation state object. - **trackIndex** (*int*) - The index of the track. - **mixDuration** (*float*) - The duration of the crossfade to the setup pose. - **delay** (*float*) - The delay before the crossfade starts (for `setEmptyAnimation`). ### Request Example ```c // Whatever is currently playing on track 0, clear the track and crossfade // to the setup pose for 0.5 seconds (mix time) with a delay of 1 second. spAnimationState_setEmptyAnimation(animationState, 0, 0.5f, 1); // Add a crossfade to the setup pose for 0.5 seconds as part of the animation // sequence in track 0 spAnimationState_addEmptyAnimation(animationState, 0, 0.5f) ``` ``` -------------------------------- ### PixiJS V7 BunnyMark Setup and Animation Loop Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-pixi-v7/example/bunnymark.html This is the main asynchronous function that sets up the PixiJS renderer, loads Spine assets, creates a specified number of animated bunnies, and starts the rendering loop. It also handles adding new bunnies on mouse click. ```javascript (async () => { const params = new URLSearchParams(window.location.search); const totalBunnies = parseInt(params.get('count')) || 100; const bunnyPool = []; const renderer = new PIXI.Renderer({ clearBeforeRender: true, backgroundAlpha: 1, backgroundColor: 0xFFFFFF, width: 800, height: 600, resolution: 1, antialias: false, }) document.body.appendChild(renderer.view) const stage = new PIXI.Container(); PIXI.Assets.add({ alias: "spineboyData", src: "/assets/spineboy-pro.skel" }); PIXI.Assets.add({ alias: "spineboyAtlas", src: "/assets/spineboy-pma.atlas" }); await PIXI.Assets.load(["spineboyData", "spineboyAtlas"]); const bounds = new PIXI.Rectangle(0, 0, 800, 600); const bunnies = [] function addBunny() { const bunny = new BunnyV7(bounds) stage.addChild(bunny.view); bunnies.push(bunny); } for (let i = 0; i < totalBunnies; i++) { addBunny(); } let pause = false; renderer.view.addEventListener('mousedown', () => { pause = !pause addBunny(); }) function renderUpdate() { if (!pause) { for (let i = 0; i < bunnies.length; i++) { bunnies[i].update(); } } renderer.render(stage); requestAnimationFrame(renderUpdate) } renderUpdate() })(); ``` -------------------------------- ### Install Application Executable Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-flutter/example/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. This makes the application runnable after installation. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Dependencies Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-flutter/codegen/README.md Run this command to install the necessary Node.js dependencies for the codegen process. ```bash npm install ``` -------------------------------- ### Build Spine-GLFW Example Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/todos/done/2025-01-21-10-06-07-cpp-clipping-broken.md Compiles the spine-glfw example application using CMake to test the corrected clipping implementation with the portal animation. ```bash cd spine-glfw && cmake -B build && cmake --build build ``` -------------------------------- ### Installation Bundle Configuration Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-flutter/example/linux/CMakeLists.txt Configures the installation prefix to create a relocatable bundle in the build directory and ensures a clean bundle directory on each build. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Install Dependencies for Linux Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-glfw/README.md Install necessary development packages on Ubuntu/Debian for building spine-glfw. ```bash sudo apt-get install cmake ninja-build libgl1-mesa-dev libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev # Ubuntu/Debian # or equivalent for your distribution ``` -------------------------------- ### Play Skeleton Animation Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-webcomponents/example/tutorial.html A simple example to get a skeleton and set its animation. This is a basic setup for starting an animation on a skeleton. ```javascript const celeste = spine.getSkeleton("celeste"); await celeste.whenReady; celeste.state.setAnimation(0, "swing", true); ``` -------------------------------- ### Initial Load and UI Setup Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-webgl/tests/test-additive-animation-blending.html Calls the setupUI function and initiates the loading process for the Spine assets. ```javascript setupUI(); load(); ``` -------------------------------- ### Handling Animation Events Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-player/example/embedding-json-example.html This example shows how to subscribe to and handle animation events, such as when an animation starts, loops, or completes. ```javascript json.player.on('event', function (name) { console.log('Animation event:', name); }); json.player.on('complete', function () { console.log('Animation completed.'); }); json.player.on('dispose', function () { console.log('Player disposed.'); }); ``` -------------------------------- ### Phaser Scene Setup and Asset Loading Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-phaser-v4/example/move-origin.html Sets up the Phaser scene, loads Spine binary and atlas data, and loads a block image. This is boilerplate for Phaser Spine examples. ```typescript let cursors; let spineboy; const levelWidth = 800; const levelHeight = 600; const gameobjects = []; class BasicExample extends Phaser.Scene { preload() { this.load.spineBinary("spineboy-data", "/assets/spineboy-pro.skel"); this.load.spineAtlas("spineboy-atlas", "/assets/spineboy-pma.atlas"); this.load.image("block", "block.png"); } create() { // ... scene creation logic ... ``` -------------------------------- ### Logging Pattern Example Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/formatters/logging/README.md Demonstrates a common pattern for logging build steps, capturing command output, and handling errors using log_action, log_ok, log_fail, and log_error_output. ```bash log_title "Spine-C++ Build" log_action "Configuring debug build" if CMAKE_OUTPUT=$(cmake --preset=debug . 2>&1); then log_ok else log_fail log_error_output "$CMAKE_OUTPUT" exit 1 fi log_action "Building" if BUILD_OUTPUT=$(cmake --build --preset=debug 2>&1); then log_ok else log_fail log_error_output "$BUILD_OUTPUT" exit 1 fi ``` -------------------------------- ### CMake FetchContent Integration Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-cpp/docs.md This CMakeLists.txt example shows how to use `FetchContent` to integrate the spine-c runtime into your project, starting from Spine version 4.2. Ensure your CMake version is 3.14 or higher. ```cmake cmake_minimum_required(VERSION 3.14) project(MyProject C) set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) set(FETCHCONTENT_QUIET NO) ``` -------------------------------- ### Clone and Open Example Project Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ios/README.md Clone the spine-runtimes repository and navigate to the spine-ios directory to open the example project in Xcode. This allows you to run and explore the various features demonstrated. ```bash git clone https://github.com/esotericsoftware/spine-runtimes cd spine-runtimes/spine-ios open Example/Spine\ iOS\ Example.xcodeproj ``` -------------------------------- ### HTML Structure for Spine Player Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-player/example/embedding-binary-example.html Basic HTML setup required to host the Spine player canvas. This includes the canvas element and script tags for the Spine player library and the example code. ```html Spine Player Binary Example ``` -------------------------------- ### Loading and Initial Setup Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-webgl/tests/test-slot-range.html Continuously checks if assets are loaded. Once complete, it loads two skeletons, adjusts the camera to fit the main skeleton, and sets initial animations. ```javascript function load() { if (assetManager.isLoadingComplete()) { spineBoy = loadSkeleton("spineboy-pro.json", "spineboy-pma.atlas", 1); vine = loadSkeleton("vine-pro.json", "vine-pma.atlas", 0.3); var offset = new spine.Vector2(); var size = new spine.Vector2(); spineBoy.skeleton.updateWorldTransform(spine.Physics.update); spineBoy.skeleton.getBounds(offset, size, []); renderer.camera.position.x = offset.x + size.x / 2; renderer.camera.position.y = offset.y + size.y / 2; renderer.camera.zoom = size.x > size.y ? size.x / canvas.width : size.y / canvas.height; spineBoy.animationState.setAnimation(0, "walk", true); vine.animationState.setAnimation(0, "grow", true); requestAnimationFrame(render); } else { loadingScreen.draw(false); requestAnimationFrame(load); } } ``` -------------------------------- ### Load Skeleton Assets and Setup UI Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-webgl/example/index.html Continuously checks if all assets are loaded. Once complete, it loads skeleton data using either binary or JSON format, sets up the UI, and starts the rendering loop. ```typescript function load() { // Wait until the AssetManager has loaded all resources, then load the skeletons. if (assetManager.isLoadingComplete()) { skeletons = { coin: { Binary: loadSkeleton("coin-pro.skel", "animation"), JSON: loadSkeleton("coin-pro.json", "animation") }, goblins: { Binary: loadSkeleton("goblins-pro.skel", "walk", "goblin"), JSON: loadSkeleton("goblins-pro.json", "walk", "goblin") }, "mix-and-match-pro": { Binary: loadSkeleton("mix-and-match-pro.skel", "dance", "full-skins/girl-blue-cape"), JSON: loadSkeleton("mix-and-match-pro.json", "dance", "full-skins/girl-blue-cape") }, raptor: { Binary: loadSkeleton("raptor-pro.skel", "walk"), JSON: loadSkeleton("raptor-pro.json", "walk") }, spineboy: { Binary: loadSkeleton("spineboy-pro.skel", "run"), JSON: loadSkeleton("spineboy-pro.json", "run") }, stretchyman: { Binary: loadSkeleton("stretchyman-pro.skel", "sneak"), JSON: loadSkeleton("stretchyman-pro.json", "sneak") }, tank: { Binary: loadSkeleton("tank-pro.skel", "drive"), JSON: loadSkeleton("tank-pro.json", "drive") }, vine: { Binary: loadSkeleton("vine-pro.skel", "grow"), JSON: loadSkeleton("vine-pro.json", "grow") } }; setupUI(); lastFrameTime = Date.now() / 1000; requestAnimationFrame(render); // Loading is done, call render every frame. } else requestAnimationFrame(load); } ``` -------------------------------- ### Project and Dependency Setup Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-sfml/CMakeLists.txt Initializes the CMake project and includes the SFML library using FetchContent. Ensures SFML is available for the project. ```cmake cmake_minimum_required(VERSION 3.16) project(spine-sfml VERSION 4.3.0 LANGUAGES C CXX) option(BUILD_EXAMPLES "Build examples" ON) # Default flags include(${CMAKE_CURRENT_LIST_DIR}/../flags.cmake) # SFML include(FetchContent) set(BUILD_SHARED_LIBS OFF) FetchContent_Declare( SFML GIT_REPOSITORY https://github.com/SFML/SFML GIT_TAG 2.6.1 ) FetchContent_MakeAvailable(SFML) ``` -------------------------------- ### Programmatic Skeleton Creation and Appending Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-webcomponents/example/tutorial.html This example demonstrates programmatic creation of Spine skeletons using `spine.createSkeleton`. It highlights the use of `manual-start` and the asynchronous `appendTo` method, emphasizing the need to manually call `start()` and wait for `whenReady`. ```javascript spine.createSkeleton({ // ... skeleton configuration ... manualStart: false }).then(widget => { document.body.appendChild(widget.domElement); widget.start(); return widget.whenReady(); }).then(skeleton => { // Interact with the skeleton here }); ``` -------------------------------- ### Spine Pixi Mouse Following Setup Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-pixi-v7/example/mouse-following.html Initializes PixiJS, loads Spine assets, creates a Spine object, sets animations, and adds interactivity for mouse following. Ensure Spineboy assets are correctly path-ed. ```javascript var app = new PIXI.Application({ width: window.innerWidth, height: window.innerHeight, resolution: window.devicePixelRatio || 1, autoDensity: true, resizeTo: window, backgroundColor: 0x2c3e50, hello: true, }); document.body.appendChild(app.view); // Pre-load the skeleton data and atlas. You can also load .json skeleton data. PIXI.Assets.add("spineboyData", "/assets/spineboy-pro.skel"); PIXI.Assets.add("spineboyAtlas", "/assets/spineboy-pma.atlas"); await PIXI.Assets.load([ "spineboyData", "spineboyAtlas", ]); // Create the spine display object const spineboy = new spine.Spine({ skeleton: "spineboyData", atlas: "spineboyAtlas", scale: 0.5, }); // Set the default mix time to use when transitioning // from one animation to another. spineboy.state.data.defaultMix = 0.2; // Set looping animations "idle" on track 0 and "aim" on track 1. spineboy.state.setAnimation(0, "idle", true); spineboy.state.setAnimation(1, "aim", true); // Center the Spine object on screen. spineboy.x = window.innerWidth / 2; spineboy.y = window.innerHeight / 2 + spineboy.getBounds().height / 2; // Add the display object to the stage. app.stage.addChild(spineboy); // Make the stage interactive and register pointer events app.stage.eventMode = "dynamic"; app.stage.hitArea = app.screen; let isDragging = false; app.stage.on("pointerdown", (e) => { isDragging = true; setBonePosition(e); }); app.stage.on("pointermove", (e) => { if (isDragging) setBonePosition(e); }); app.stage.on("pointerup", (e) => (isDragging = false)); const setBonePosition = (e) => { // Transform the mouse/touch coordinates to Spineboy's coordinate // system origin. `position` is then relative to Spineboy's root // bone. const position = new spine.Vector2( e.data.global.x - spineboy.x, e.data.global.y - spineboy.y ); // Find the crosshair bone. const crosshairBone = spineboy.skeleton.findBone("crosshair"); // Take the mouse position, which is relative to the root bone, // and transform it to the crosshair bone's parent root bone // coordinate system via `worldToLocal()`. // `position` is relative to the crosshair bone's parent bone after this crosshairBone.parent.pose.worldToLocal(position); // Set the crosshair bone's position to the mouse position crosshairBone.pose.x = position.x; crosshairBone.pose.y = position.y; }; })(); ``` -------------------------------- ### Complete spine-c Integration Example Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-c/docs.md This example shows the full lifecycle of using spine-c, from loading assets and setting up animation states to updating and rendering multiple skeletons in a game loop. It emphasizes proper resource management and animation sequencing. ```c // Setup pose data, shared by all skeletons spAtlas* atlas; spSkeletonData* skeletonData; spAnimationStateData* animationStateData; // 5 skeleton instances and their animation states spSkeleton* skeleton[5]; spAnimationState* animationState[5]; char* animationNames[] = { "walk", "run", "shot" }; void setup() { // setup your engine so textures can be loaded for atlases, create a window, etc. engine_setup(); // Load the texture atlas atlas = spAtlas_createFromFile("spineboy.atlas", 0); if (!atlas) { printf("Failed to load atlas"); exit(0); } // Load the skeleton data spSkeletonJson* json = spSkeletonJson_create(atlas); skeletonData = spSkeletonJson_readSkeletonDataFile(json, "spineboy.json"); if (!skeletonData) { printf("Failed to load skeleton data"); spAtlas_dispose(atlas); exit(0); } spSkeletonJson_dispose(json); // Setup mix times animationStateData = spAnimationStateData_create(skeletonData); animationStateData->defaultMix = 0.5f; spAnimationStateData_setMixByName("walk", "run", 0.2f); spAnimationStateData_setMixByName("walk", "shot", 0.1f); } void mainLoop() { // Create 5 skeleton instances and animation states // representing 5 game objects for (int i = 0; i < 5; i++) { // Create the skeleton and put it at a random position spSkeleton* skeleton = spSkeleton_create(skeletonData); skeleton->x = random(0, 200); skeleton->y = random(0, 200); // Create the animation state and enqueue a random animation, looping spAnimationState animationState = spAnimationState_create(animationStateData); spAnimationState_setAnimation(animationState, 0, animationNames[random(0, 3)], 1); } while (engine_gameIsRunning()) { engine_clearScreen(); // update the game objects for (int i = 0; i < 5; i++) { spSkeleton* skeleton = skeletons[i]; spAnimationState* animationState = animationStates[i]; // First update the animation state by the delta time spAnimationState_update(animationState, engine_getDeltaTime()); // Next, apply the state to the skeleton spAnimationState_apply(animationState, skeleton); // Update the skeleton's frame time for physics spSkeleton_update(engine_getDeltaTime()); // Calculate world transforms for rendering spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); // Hand off rendering the skeleton to the engine engine_drawSkeleton(skeleton); } } // Dispose of the instance data. Normally you'd do this when // a game object is disposed. for (int i = 0; i < 5) { spSkeleton_dispose(skeleton); spAnimationState_dispose(animationState); } } void dispose() { // dispose all the shared resources spAtlas_dispose(atlas); spSkeletonData_dispose(skeletonData); spAnimationStateData_dispose(animationStateData); } int main(int argc, char* argv) { setup(); mainLoop(); dispose(); } ``` -------------------------------- ### Install Spine-Haxe Dependencies Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-haxe/README.md Install the necessary libraries for spine-haxe before installing the runtime itself. These are required for rendering. ```bash haxelib install openfl haxelib install starling haxelib install flixel ``` -------------------------------- ### Define Installation Directories for Bundle Data and Libraries Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-flutter/example/windows/CMakeLists.txt Specifies the destination directories for installing application data (like assets) and libraries within the installation prefix. This organizes the installed application structure. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Setup Spine-Haxe Development Environment Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-haxe/README.md Configure your development environment by setting up haxelib and cloning the spine-runtimes repository. This allows for local development and debugging. ```bash haxelib setup haxelib install openfl haxelib run openfl setup haxelib install starling haxelib install flixel ``` ```bash git clone https://github.com/esotericsoftware/spine-runtimes cd spine-runtimes haxelib dev spine-haxe . ``` -------------------------------- ### Install Spine-Haxe Runtime Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-haxe/README.md After installing dependencies, download and install the spine-haxe library using a zip archive. It is not available on lib.haxe.org. ```bash haxelib install spine-haxe-x.y.z.zip ``` -------------------------------- ### Initialize Spine Player with Binary Data Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-player/example/embedding-binary-example.html This snippet shows the basic setup for initializing the Spine player. It involves creating a Spine instance and loading a binary animation file. ```javascript var canvas = document.getElementById("mycanvas"); var spine = new spine.SpinePlayer(canvas); spine.addSpine("spineboy.spine", "spineboy.atlas", 0.5, true, function (spine) { spine.setAnimation("walk", "walk", true); }); ``` -------------------------------- ### Setup clang-format via Docker Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/formatters/README.md Helper script for GitHub Actions to set up clang-format 18.1.8 using Docker. Creates a wrapper script to ensure version consistency. ```bash ./setup-clang-format-docker.sh ``` -------------------------------- ### Add Dependencies for Spine-GLFW Examples Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-glfw/CMakeLists.txt Ensures that various Spine-GLFW examples depend on the 'spine-glfw-data' target, guaranteeing that data files are copied before the examples are built. ```cmake add_dependencies(spine-glfw-example spine-glfw-data) add_dependencies(spine-glfw-example-c spine-glfw-data) add_dependencies(spine-glfw-dragon spine-glfw-data) add_dependencies(spine-glfw-dragon-c spine-glfw-data) add_dependencies(spine-glfw-dragon-json spine-glfw-data) add_dependencies(spine-glfw-dragon-json-c spine-glfw-data) add_dependencies(spine-glfw-physics spine-glfw-data) add_dependencies(spine-glfw-physics-c spine-glfw-data) add_dependencies(spine-glfw-ik-following spine-glfw-data) add_dependencies(spine-glfw-ik-following-c spine-glfw-data) add_dependencies(spine-glfw-mix-and-match spine-glfw-data) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-flutter/example/windows/CMakeLists.txt Installs the main Flutter library file to the root of the application bundle's installation directory. This is a core component for running Flutter applications. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Setup UI Elements Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-ts/spine-webgl/example/index.html Initializes UI elements for selecting skeleton format, skeleton name, animation, and skin. Updates UI based on user selections. ```javascript function setupUI() { const formatList = $("#formatList"); formatList.append($("")); formatList.append($("")); const skeletonList = $("#skeletonList"); for (const skeletonName in skeletons) { const option = $(""); option.attr("value", skeletonName).text(skeletonName); if (skeletonName === activeSkeleton) option.attr("selected", "selected"); skeletonList.append(option); } const setupAnimationUI = () => { const animationList = $("#animationList"); animationList.empty(); const skeleton = skeletons[activeSkeleton][format].skeleton; const state = skeletons[activeSkeleton][format].state; const activeAnimation = state.tracks[0].animation.name; for (let i = 0; i < skeleton.data.animations.length; i++) { const name = skeleton.data.animations[i].name; const option = $(""); option.attr("value", name).text(name); if (name === activeAnimation) option.attr("selected", "selected"); animationList.append(option); } animationList.change(() => { const state = skeletons[activeSkeleton][format].state; const skeleton = skeletons[activeSkeleton][format].skeleton; const animationName = $("#animationList option:selected").text(); skeleton.setupPose(); state.setAnimation(0, animationName, true); }) } const setupSkinUI = () => { const skinList = $("#skinList"); skinList.empty(); const skeleton = skeletons[activeSkeleton][format].skeleton; const activeSkin = skeleton.skin == null ? "default" : skeleton.skin.name; for (let i = 0; i < skeleton.data.skins.length; i++) { const name = skeleton.data.skins[i].name; const option = $(""); option.attr("value", name).text(name); if (name === activeSkin) option.attr("selected", "selected"); skinList.append(option); } skinList.change(() => { const skeleton = skeletons[activeSkeleton][format].skeleton; const skinName = $("#skinList option:selected").text(); skeleton.setSkinByName(skinName); skeleton.setupPose(); }) } skeletonList.change(() => { activeSkeleton = $("#skeletonList option:selected").text(); setupAnimationUI(); setupSkinUI(); }) formatList.change(() => { format = $("#formatList option:selected").text(); setupAnimationUI(); setupSkinUI(); }) setupAnimationUI(); setupSkinUI(); } ``` -------------------------------- ### Configure Installation Directory for Executable Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-flutter/example/windows/CMakeLists.txt Sets up the installation directory for the main executable, ensuring it's placed next to support files for in-place execution. This is particularly useful for Visual Studio builds. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Field Accessor Exclusion Example Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-c/codegen/README.md Examples of how to exclude field getters, setters, or both. ```plaintext field: AtlasRegion::names # Exclude both getter and setter ``` ```plaintext field-get: SecretData::password # Exclude only getter ``` ```plaintext field-set: Bone::x # Exclude only setter ``` -------------------------------- ### Create Spine-SDL-C Example Executable Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-sdl/CMakeLists.txt Builds an example executable for Spine-SDL-C. It links against SDL2-static and the spine-sdl-c library. The working directory for the debugger is set. ```cmake add_executable(spine-sdl-c-example example/main.c) target_link_libraries(spine-sdl-c-example SDL2-static spine-sdl-c) set_property(TARGET spine-sdl-c-example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/spine-sdl") ``` -------------------------------- ### Constructor Exclusion Example Source: https://github.com/esotericsoftware/spine-runtimes/blob/4.3/spine-c/codegen/README.md Example of how to prevent instantiation of a type by excluding its constructor. ```plaintext method: AtlasRegion::AtlasRegion ```