19个不稳定版本 (3个重大变更)
0.4.1 | 2023年4月6日 |
---|---|
0.4.0 | 2023年3月20日 |
0.3.0 | 2023年3月11日 |
0.2.4 | 2023年2月1日 |
0.1.8 | 2022年9月30日 |
#1781 in 游戏开发
每月下载量170
33KB
142 代码行
bevy_mod_ui_texture_atlas_image
使用Bevy UI从纹理图集绘制图像。
- 版本0.3和0.4支持Bevy 0.10
- 版本0.2支持Bevy 0.9
- 版本0.1支持Bevy 0.8
详细信息
要使用此包,将它的依赖添加到项目的Cargo.toml
bevy_mod_ui_texture_atlas_image = "0.3"
或使用Cargo
cargo add bevy_mod_ui_texture_atlas_image
组件
-
UiAtlasImage
节点的纹理图集图像。
-
ImageTint
图像的着色颜色。
包
-
AtlasImageBundle
显示从
TextureAtlas
中获取的图像所需的组件包。
插件
必须将UiAtlasImagePlugin
插件添加到您的Bevy应用中
use bevy_mod_ui_texture_atlas_image::*;
fn main () {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(UiAtlasImagePlugin)
// ..rest of app
.run()
}
然后您可以使用AtlasImageBundle
来绘制来自TextureAtlas
的图像
commands
.spawn(AtlasImageBundle {
atlas_image: UiAtlasImage {
atlas: texture_atlas_handle.clone(),
index: 5
},
..Default::default()
});
AtlasImageBundle
和ImageBundle
之间的区别是
- 而不是
UiImage
组件,AtlasImageBundle
有一个UiAtlasImage
组件,该组件设置了节点显示的图像。 - 而不是
BackgroundColor
组件,AtlasImageBundle
有一个ImageTint
组件,该组件设置了图像的颜色着色。
示例
- 从纹理图集显示单个图像
cargo --run --example minimal
- 显示纹理图集网格中的三个瓦片以及图集的源图像
cargo --run --example tiles
- 显示具有alpha通道的纹理图集中的图像
cargo --run --example alpha
- 显示具有裁剪的纹理图集中的图像
cargo --run --example clipped
依赖项
~19–54MB
~885K SLoC