Crates.io | bevy_2dviewangle |
lib.rs | bevy_2dviewangle |
version | |
source | src |
created_at | 2024-01-26 09:23:16.208264 |
updated_at | 2024-12-06 03:55:27.408276 |
description | Bevy plugin for easier to switch texture base on view angles |
homepage | |
repository | https://gitlab.com/kimtinh/bevy-2dviewangle |
max_upload_size | |
id | 1115343 |
Cargo.toml error: | TOML parse error at line 25, column 1 | 25 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Bevy plugin to easier to manage and switch texture base on view angles.
// Struct to store sprite sheet
#[derive(View2dCollection, Default)]
struct MyAssets {
#[textureview(actor = "player", action = "idle", angle = "front")]
pub idle_front: Handle<Image>,
// If not specify actor/action, the previous value will be used
#[textureview(angle = "back")]
pub idle_back: Handle<Image>,
// If the angle "right" is not defined, it will be flipped base on the "left" image
#[textureview(angle = "left")]
pub idle_left: Handle<Image>,
// If angle is any, other angle which has not been defined will use this value
#[textureview(angle = "any")]
pub idle_any_layout: Handle<TextureAtlasLayout>,
}
// Change the sprite sheet by sending event
fn switch_sprite(
mut actors: Query<(&mut View2dActor, Entity)>,
mut action_event: EventWriter<ViewChanged>,
) {
for (mut act, e) in actors.iter_mut() {
act.action = ActionMyAssets::Idle;
act.angle = AngleMyAssets::Right;
action_event.send(ViewChanged { entity: e });
}
}
Please see in examples for more detail.
This plugin can work with bevy_asset_loader too:
#[derive(AssetCollection, View2dCollection, Resource)]
pub struct MyAssets {
#[asset(path = "frog_idle_front.png")]
#[textureview(actor = "frog", action = "idle", angle = "front")]
pub idle_front: Handle<Image>,
#[asset(path = "frog_idle_back.png")]
#[textureview(angle = "back")]
pub idle_back: Handle<Image>,
#[asset(path = "frog_idle_left.png")]
#[textureview(angle = "left")]
pub idle_left: Handle<Image>,
#[asset(texture_atlas_layout(tile_size_x = 16, tile_size_y = 16, columns = 1, rows = 3))]
#[textureview(angle = "any")]
pub any_layout: Handle<TextureAtlasLayout>,
}
Please see LICENSE.
bevy | bevy_2dviewangle |
---|---|
0.15 | 0.9, branch master |
0.14 | 0.7-0.8 |
0.13 | 0.2-0.6 |
0.12 | 0.1 |