Crates.io | micro_bevy_splash |
lib.rs | micro_bevy_splash |
version | 0.1.0 |
source | src |
created_at | 2024-05-18 00:20:47.70144 |
updated_at | 2024-05-18 00:20:47.70144 |
description | Simple, one-shot logo splash screen for Bevy |
homepage | |
repository | https://lab.lcr.gr/microhacks/bevy-splash |
max_upload_size | |
id | 1243825 |
size | 27,031 |
A simple, one-shot logo splash screen plugin for Bevy
Render a splash screen logo with optional tweening that will subsequently transition to another state when complete.
A basic use case for splash screens is to provide visual interest while loading assets. To achieve this, you can perform the following flow:
micro_bevy_splash
to render in your splash state via the plugin settings, and transition
to that state once loading has begunmicro_bevy_splash
via the plugin settingsInclude micro_bevy_splash
in your project's Cargo.toml
[dependencies]
micro_bevy_splash = "0.1.0"
and then configure the plugin for your app, including what state to render in, and what state to transition to.
The states can be any type that implements the States
trait from bevy
, but both states must be of the
same concrete type - typically an enum
use micro_bevy_splash::{MicroSplashPlugin, SplashSettings};
// Import all of the usual bevy libraries here
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, States, Default)]
enum AppState {
Preload,
Setup,
Splash,
Menu,
}
fn main() {
App::new()
.add_plugins((
DefaultPlugins::default(),
MicroSplashPlugin::with_settings(SplashSettings {
// Specify when the plugin runs, and what it transitions to
run_in: AppState::Splash,
transition_to: AppState::Menu,
// Specify the asset path that the default bevy asset server will
// use to look up the splash logo to display, and the musical sting
// that will play over the screen
logo_path: String::from("splash/splash_clean.png"),
sting_path: String::from("splash/sting.ogg"),
// Allow users to press Space, Return, or Escape to skip to the exit state
skip_on_input: true,
// How long to stay on this screen. This differs from any time spent tweening
// the assets, as you typically want to hang on a static view of the logo
// for some short period of time
duration: Duration::from_secs(3),
// Specify tween values for animating the background colour and the logo colour
// These can be specified independently, and providing `None` will not tween
// that component
bg_color_tween: Some((Color::Black, Color::Red)),
tween_duration: Some(Duration::from_secs(2)),
logo_color_tween: None,
})
))
.run();
}
micro_bevy_splash | bevy |
---|---|
0.1.0 | 0.13.x |