siiir-bevy_fancy_cursor

Crates.iosiiir-bevy_fancy_cursor
lib.rssiiir-bevy_fancy_cursor
version0.4.3
sourcesrc
created_at2024-05-06 18:14:26.511961
updated_at2024-05-06 19:04:14.608612
descriptionFacilitates creating custom cursor in bevy-based app. Uses bevy's `ImageBundle` to replace the original cursor with moving UI element.
homepagehttps://github.com/siiir/bevy_fancy_cursor
repositoryhttps://github.com/siiir/bevy_fancy_cursor
max_upload_size
id1231344
size166,716
Tomasz Nehring (Siiir)

documentation

README

bevy_fancy_cursor

Facilitates creating a custom cursor in bevy-based app. Uses bevy's ImageBundle to replace the original cursor with a moving UI element.

Instalation

From inside of your project

  • run:
    cargo add siiir-bevy_fancy_cursor

  • or add to manifest file (Cargo.toml) under [dependencies]
    bevy_fancy_cursor = { git = "https://github.com/Siiir/bevy_fancy_cursor" }

Example usage

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Plugin does its job in `bevy::app::StartupStage::PostStartup` when camera is already spawned.
        .add_plugin(
            bevy_fancy_cursor::CursorSettings::basic()
                .img_path("fancy cursor.png")
                .size(Size::new(Val::Px(50.0), Val::Px(70.0)))
                .build()
        )
        // You can spawn camera in `bevy::app::StartupStage::Startup`, which is (AND MUST BE) BEFORE `PostStartup`.
        .add_startup_system(spawn_camera)
        .run()
}

fn spawn_camera(mut commands: Commands){
    commands.spawn((
        bevy_fancy_cursor::UserCamera, // Obligatory marker for user camera. Other cameras will be ignored and won't get special cursor.
        Camera2dBundle::default(),
    ));
}

Produces this app with a fancy cursor from the "./assets" folder.

Image picturing resulting app.

To run the above example with contained asset.

Download the version I used when creating it. cargo run it. Enjoy.

Documentation

Contribute

if you want to see project growing and FancyCursor becoming more generic.

Contact

tomasz_nehring@outlook.com

Commit count: 40

cargo fmt