12 releases

new 0.1.11 Jan 30, 2025
0.1.10 Jan 26, 2025

#192 in Video

Download history 691/week @ 2025-01-22

691 downloads per month

MIT license

13KB
278 lines

rusty_dragonbones

Runtime for DragonBones animations.

Installation

cargo add rusty_dragonbones

Usage

First, load a DragonBones root:

use rusty_dragonbones::runtime::{load_dragon_bones};

let root: DragonBonesRoot = load_dragon_bones("/path/to/*ske.json").expect("");

From here, animations can be called via animate(), which will return a bunch of props:

use rusty_dragonbones::runtime::{animate};

let mut props: Vec<Prop> = animate(&dbroot, 0, game_frame);

Props contain the properties of all bones in the animation at their specified frame. They can be used to animate like so:

let mut props: Vec<Prop> = animate(&dbroot, 0, game_frame);
for p in props {
    draw_image(img, p.pos.x, p.pos.y, p.scale.x, p.scale.y, p.rot);
}

This is a simplified example. In practice, you will most likely have to adjust the values here and there.

Missing Features

  • Only reads and makes use of `*ske.json files
  • Only does linear tweening
  • Very bare-bones; not much for quality-of-life features

Dependencies

~7.5MB
~137K SLoC