#bevy-plugin #bevy #graphics #gamedev

bevy_flicker

An easy to use event-based system to apply brief overlays to sprites and meshes

8 releases (5 breaking)

0.6.0 Jul 13, 2024
0.5.0 Feb 18, 2024
0.4.0 Nov 9, 2023
0.3.0 Aug 1, 2023
0.1.1 May 20, 2023

#270 in Game dev

Unlicense

77KB
493 lines

Bevy Flicker

This plugin facilitates creating a brief overlay/mix of a specific color over a sprite or mesh.

To trigger a flicker, you can send a FlickerStartEvent, which will contain the parameters that dictate the color, length, and strength of the flicker.

Included is also a RepeatingFlicker component that will send a FlickerStartEvent on an interval.

This also works on textures with alpha, the overlay takes into account the alpha of the underlying texture and will adjust the overlay alpha so that it's intensity is proportional between different underlying alpha values. So an underlying 0.2 alpha value will reduce the alpha of the overlay by 80%. For alpha values of 0, the overlay's alpha will also be 0.
See this alpha example for a visual of this effect, you will notice that the underlying color is still looks consistent across the sprite.

See more, complete examples (some shown below) here

use bevy_flicker::prelude::*;

fn tick(query: Query<Entity>, mut event_writer: EventWriter<FlickerStartEvent>) {
    for e in query.iter() {
        event_writer.send(
            FlickerStartEvent::builder(e)
                .with_secs(0.5)
                .with_color(Color::rgba(0.0, 0.0, 1.0, 0.2))
                .build(),
        );
    }
}


Visual Examples

cargo run --example sprite_flicker
svuL4w_7

cargo run --example mesh_flicker
5b-1OxIy

cargo run --example alpha_flicker
lzwT7Hl-

Dependencies

~39–77MB
~1.5M SLoC