Crates.io | bevy_2d_menu_mask_transition |
lib.rs | bevy_2d_menu_mask_transition |
version | 0.1.1 |
source | src |
created_at | 2024-09-02 10:23:07.574527 |
updated_at | 2024-09-02 11:50:38.303319 |
description | A Bevy plugin for creating smooth menu transitions with customizable masks. |
homepage | https://github.com/Lan-Game-Studios/bevy-2d-menu-mask-transitions |
repository | https://github.com/Lan-Game-Studios/bevy-2d-menu-mask-transitions |
max_upload_size | |
id | 1360366 |
size | 130,628 |
This project is a Bevy plugin that enables smooth menu transitions in Bevy applications or games. It provides a way to create visually appealing transitions between different game states, such as transitioning from a menu screen to gameplay. The plugin takes a screenshot of the current frame, applies a transition effect using a shader and a mask texture, and transitions to the new state.
Menu
and InGame
.To include this plugin in your Bevy project, add the following to your Cargo.toml
:
cargo add bevy_2d_menu_mask_transition
Initialize the Plugin:
In your main file (e.g., main.rs
), initialize the MenuTransitionPlugin
by adding it to your Bevy app:
use bevy::prelude::*;
use bevy_2d_menu_mask_transition::{MenuTransitionPlugin, TriggerMenuTransition};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(MenuTransitionPlugin::<YourState>::default())
.run();
}
Define Your Game States: Create an enum to represent the various states in your game:
Debug
is required, but only used for debug level logging
#[derive(States, Clone, Copy, PartialEq, Eq, Hash, Debug, Default)]
enum YourState {
#[default]
Menu,
InGame,
}
Trigger Transitions:
You can trigger transitions between states using the TriggerMenuTransition
event. For example, this can be tied to a button press:
#[derive(Component, Default)]
struct Navigate(YourState);
fn interact(
mut query: Query<(&Interaction, &Navigate), With<Button>>,
mut writer: EventWriter<TriggerMenuTransition<YourState>>,
asset_server: Res<AssetServer>,
) {
for (interaction, navigate) in query.iter_mut() {
if *interaction == Interaction::Pressed {
writer.send(TriggerMenuTransition {
target_state: navigate.0,
duration: Duration::from_secs_f32(1.0),
mask: asset_server.load("path/to/mask.png"),
});
}
}
}
If you'd like to contribute to this plugin, feel free to submit issues or pull requests on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for more details.
Bevy - A data-driven game engine built in Rust.
The Bevy community for providing a robust and flexible game development framework.
Version | Bevy Version |
---|---|
0.1.x | 0.14 |
This crate is part of an effort to crate a game studio. Checkout Mega Giga Cookie Destoryer TD or the mission of Lan Game Studios if you like games or game development.