Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dothanhtrung/bevy-2dviewangle
Bevy plugin to manage 2d texture in different view angles
https://github.com/dothanhtrung/bevy-2dviewangle
bevy bevy-plugin rust
Last synced: about 1 month ago
JSON representation
Bevy plugin to manage 2d texture in different view angles
- Host: GitHub
- URL: https://github.com/dothanhtrung/bevy-2dviewangle
- Owner: dothanhtrung
- License: other
- Created: 2023-10-23T06:28:18.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-16T18:39:04.000Z (8 months ago)
- Last Synced: 2024-04-20T06:52:00.767Z (8 months ago)
- Topics: bevy, bevy-plugin, rust
- Language: Rust
- Homepage: https://gitlab.com/kimtinh/bevy-2dviewangle
- Size: 63.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
bevy_2dviewangle
================[![crates.io](https://img.shields.io/crates/v/bevy_2dviewangle)](https://crates.io/crates/bevy_2dviewangle)
[![docs.rs](https://docs.rs/bevy_2dviewangle/badge.svg)](https://docs.rs/bevy_2dviewangle)
[![dependency status](https://deps.rs/repo/gitlab/kimtinh/bevy-2dviewangle/status.svg)](https://deps.rs/repo/gitlab/kimtinh/bevy-2dviewangle)
[![pipeline status](https://gitlab.com/kimtinh/bevy-2dviewangle/badges/master/pipeline.svg)](https://gitlab.com/kimtinh/bevy-2dviewangle/-/commits/master)![](examples/2d.mp4)
![](examples/3d.mp4)
Bevy plugin to easier to manage and switch texture base on view angles.
Quickstart
----------```rust
// Struct to store sprite sheet
#[derive(View2dCollection, Default)]
struct MyAssets {
#[textureview(actor = "player", action = "idle", angle = "front")]
pub idle_front: Handle,// If not specify actor/action, the previous value will be used
#[textureview(angle = "back")]
pub idle_back: Handle,// If the angle "right" is not defined, it will be flipped base on the "left" image
#[textureview(angle = "left")]
pub idle_left: Handle,// If angle is any, other angle which has not been defined will use this value
#[textureview(angle = "any")]
pub idle_any_layout: Handle,
}
``````rust
// Change the sprite sheet by sending event
fn switch_sprite(
mut actors: Query<(&mut View2dActor, Entity)>,
mut action_event: EventWriter,
) {
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](./examples) for more detail.
This plugin can work with [bevy_asset_loader](https://crates.io/crates/bevy_asset_loader) too:
```rust
#[derive(AssetCollection, View2dCollection, Resource)]
pub struct MyAssets {
#[asset(path = "frog_idle_front.png")]
#[textureview(actor = "frog", action = "idle", angle = "front")]
pub idle_front: Handle,#[asset(path = "frog_idle_back.png")]
#[textureview(angle = "back")]
pub idle_back: Handle,#[asset(path = "frog_idle_left.png")]
#[textureview(angle = "left")]
pub idle_left: Handle,#[asset(texture_atlas_layout(tile_size_x = 16, tile_size_y = 16, columns = 1, rows = 3))]
#[textureview(angle = "any")]
pub any_layout: Handle,
}
```License
-------Please see [LICENSE](./LICENSE).
Compatible Bevy Versions
------------------------| 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 |