#bevy #bevy-plugin #graphics #gamedev

bevy_flicker

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

7 releases (4 breaking)

0.5.0 Feb 18, 2024
0.4.0 Nov 9, 2023
0.3.0 Aug 1, 2023
0.2.0 Jun 22, 2023
0.1.1 May 20, 2023

#851 in Game dev

Download history 118/week @ 2024-02-14 43/week @ 2024-02-21 10/week @ 2024-02-28 2/week @ 2024-03-06 3/week @ 2024-03-13 31/week @ 2024-03-27 39/week @ 2024-04-03

70 downloads per month

Unlicense

76KB
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–80MB
~1M SLoC