#sprite-sheet #bevy #bevy-plugin #assets #gamedev #textureatlas

bevy_titan

用于从sprite-sheet清单文件加载纹理图集的Bevy插件

8个版本 (有破坏性)

0.7.0 2024年7月7日
0.6.0 2024年2月18日
0.5.0 2023年11月22日
0.4.0 2023年11月8日
0.1.1 2023年2月19日

#794游戏开发

Download history 3/week @ 2024-06-03 1/week @ 2024-06-10 106/week @ 2024-07-01 52/week @ 2024-07-08 13/week @ 2024-07-29

每月170 次下载
bevy_trickfilm中使用

MIT/Apache

40KB
289 代码行

bevy_titan

crates.io Bevy tracking docs.rs MIT/Apache 2.0

bevy bevy_titan
main main
0.14 0.7.0
0.13 0.6.0
0.12 0.4.0, 0.5.0
0.11 0.3.0
0.10 0.2.0
0.9 0.1.1

什么是bevy_titan?

bevy_titan是一个简单的Bevy插件,用于从ron编写的sprite-sheet清单文件中加载纹理图集。它还支持从多个精灵和多个sprite-sheet创建纹理图集。支持热重载。

快速开始

# In your Cargo.toml
bevy_titan = "0.7"

homogeneous-sprite-sheet.titan

//! A basic example of a titan file for a homogeneous sprite sheet.
(
    textures: [
        (
            path: "path-to-homogeneous-sprite-sheet",
            sprite_sheet: Homogeneous (
                tile_size: (
                    32,
                    32,
                ),
                columns: 4,
                rows: 1,
            ),
        ),
    ]
)

heterogeneous-sprite-sheet.titan

//! A basic example of a titan file for a heterogeneous sprite sheet.
(
    textures: [
        (
            path: "path-to-heterogeneous-sprite-sheet",
            sprite_sheet: Heterogeneous (
                [
                    (
                        (0, 0),
                        (16, 16),
                    ),
                    (
                        (16, 0),
                        (32, 128),
                    ),
                    (
                        (48, 0),
                        (64, 16),
                    ),
                ]
            ),
        ),
    ]
)

main.rs

//! A basic example of how to create a TextureAtlas asset from a titan file.
use bevy::prelude::*;
use bevy_titan::SpriteSheetLoaderPlugin;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(SpriteSheetLoaderPlugin)
        .add_systems(Startup, (setup, load_texture_atlas).chain())
        .run();
}

fn setup() {Code in tests, examples and benches gets formatted with cargo fmt.
    /* Setup camera and other stuff */
}

fn load_texture_atlas(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.spawn((
        SpriteBundle {
            texture: asset_server.load("example.titan#texture"),
            transform: Transform::from_scale(Vec3::splat(6.0)),
            ..default()
        },
        TextureAtlas {
            layout: asset_server.load("example.titan#layout"),
            ..Default::default()
        }
    ));
}

文档

完整API文档

文件格式规范

示例

未来工作

  • 利用Bevy的AssetProcessor。

许可

bevy_titan是免费、开源且许可宽松的!除非另有说明(以下或单独文件中),本仓库中的所有代码均受以下任一许可证的双许可:

这意味着您可以选择您喜欢的许可证!

部分代码来自其他来源。本仓库中包含的assets受不同的开源许可证约束。请参阅CREDITS.md了解修改代码的来源和这些文件的许可证。

您的贡献

除非您明确声明,否则根据Apache-2.0许可证定义的,您有意提交以包含在本作品中的任何贡献,均应如上所述双许可,不附加任何额外条款或条件。

依赖关系

~36–72MB
~1.5M SLoC