bevy_2dviewangle

Bevy plugin to easier to switch texture base on view angles. Currently, support 8 view angles:
- front
- back
- left
- right
- front_left
- front_right
- back_left
- back_right
Quick Start
Add plugin.
App::new()
...
.add_plugins(View2DAnglePlugin)
...
Declare texture map with each actor and action with view angle.
#[derive(ActorsTexturesCollection, Default)]
struct MyAssets {
#[textureview(actor = 0, action = 0, angle = "front", handle = "image")]
pub idle_front: Handle<Image>,
#[textureview(angle = "back", handle = "image")]
pub idle_back: Handle<Image>,
#[textureview(angle = "front", handle = "atlas_layout")]
pub layout: Handle<TextureAtlasLayout>,
#[textureview(angle = "any", handle = "atlas_layout")]
pub layout: Handle<TextureAtlasLayout>,
}
Change the sprite sheet by sending event.
fn switch_sprite(
mut actors: Query<(&mut DynamicActor, Entity)>,
mut action_event: EventWriter<ViewChanged>,
) {
for (mut act, e) in actors.iter_mut() {
act.action = new_action;
act.angle = new_direction;
action_event.send(ViewChanged { entity: e });
}
}
Please see in examples for more detail.
This plugin can work with bevy_asset_loader too:
#[derive(AssetCollection, ActorsTexturesCollection, Resource)]
pub struct MyAssets {
#[asset(path = "frog_idle_front.png")]
#[textureview(actor = 0, action = 0, angle = "front", handle = "image")]
pub idle_front: Handle<Image>,
#[asset(path = "frog_idle_back.png")]
#[textureview(angle = "back", handle = "image")]
pub idle_back: Handle<Image>,
#[asset(path = "frog_idle_left.png")]
#[textureview(angle = "left", handle = "image")]
pub idle_left: Handle<Image>,
#[asset(texture_atlas_layout(tile_size_x = 16., tile_size_y = 16., columns = 1, rows = 3))]
#[textureview(angle = "any", handle = "atlas_layout")]
pub front_layout: Handle<TextureAtlasLayout>,
}
Examples
2d

2d example
3d

3d example
Use with bevy_asset_loader
asset loader example
License
Please see LICENSE.
Compatible Bevy Versions
| bevy |
bevy_2dviewangle |
| 0.13 |
0.2-0.4, branch master |
| 0.12 |
0.1 |