Skip to content

How to create a custom cursor? #8613

Closed Answered by Matheuswells
Ewan88 asked this question in Q&A
Discussion options

You must be logged in to vote

I got it working on 0.15.0, here is the code:

use bevy::prelude::*;
use bevy::render::view::RenderLayers;
use bevy::window::PrimaryWindow;
use crate::game::MainCamera;
use crate::layers::{CURSOR_LAYER};

pub(crate) struct CursorPlugin;

#[derive(Component)]
struct GameCursor {}
impl Plugin for CursorPlugin {
    fn build(&self, app: &mut App) {
        app
            .add_systems(Startup, setup)
            .add_systems(Update, (update_sprite_position_on_resize));
    }
}

fn setup(
    mut commands: Commands,
    asset_server: Res<AssetServer>,
    mut texture_atlas_layouts: ResMut<Assets<TextureAtlasLayout>>,
    mut q_window: Query<&Window, With<PrimaryWindow>>) {
    let texture = as…

Replies: 5 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@JohnReedV
Comment options

@Femto-godhand
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@Matheuswells
Comment options

@mgi388
Comment options

@Matheuswells
Comment options

Answer selected by Ewan88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants