fn character_setup(
    mut state: ResMut<State<MyStates>>,
    mut asset_keys: ResMut<AssetKeys>,
    mut show_background: ResMut<ShowBackground>,
    mouse_input: Res<Input<MouseButton>>,
    keyboard_input: Res<Input<KeyCode>>,
) {
    if mouse_input.just_pressed(MouseButton::Left) {
        // Most of the time you don't want to do this manually,
        // but load dynamic asset collections from a file.
        // See the `dynamic_asset_ron` example
        asset_keys.register_asset(
            "character",
            DynamicAsset::File {
                path: "images/female_adventurer.png".to_owned(),
            },
        );
    } else if mouse_input.just_pressed(MouseButton::Right) {
        asset_keys.register_asset(
            "character",
            DynamicAsset::File {
                path: "images/zombie.png".to_owned(),
            },
        );
    } else if keyboard_input.just_pressed(KeyCode::B) {
        show_background.0 = !show_background.0;
        return;
    } else {
        return;
    }

    if show_background.0 {
        asset_keys.register_asset(
            "background",
            DynamicAsset::File {
                path: "images/background.png".to_owned(),
            },
        );
    }
    state
        .set(MyStates::AssetLoading)
        .expect("Failed to change state");
}
// This system decides which file to load as the character sprite based on some player input
This system decides which file to load as the character sprite based on some player input
This system decides which file to load as the character sprite based on some player input
fn character_setup(
    mut state: ResMut<State<MyStates>>,
    mut asset_keys: ResMut<AssetKeys>,
    mut show_background: ResMut<ShowBackground>,
    mouse_input: Res<Input<MouseButton>>,
    keyboard_input: Res<Input<KeyCode>>,
) {
    if mouse_input.just_pressed(MouseButton::Left) {
        // Most of the time you don't want to do this manually,
        // but load dynamic asset collections from a file.
        // See the `dynamic_asset_ron` example
        asset_keys.register_asset(
            "character",
            DynamicAsset::File {
                path: "images/female_adventurer.png".to_owned(),
            },
        );
    } else if mouse_input.just_pressed(MouseButton::Right) {
        asset_keys.register_asset(
            "character",
            DynamicAsset::File {
                path: "images/zombie.png".to_owned(),
            },
        );
    } else if keyboard_input.just_pressed(KeyCode::B) {
        show_background.0 = !show_background.0;
        return;
    } else {
        return;
    }
    if show_background.0 {
        asset_keys.register_asset(
            "background",
            DynamicAsset::File {
                path: "images/background.png".to_owned(),
            },
        );
    }
    state
        .set(MyStates::AssetLoading)
        .expect("Failed to change state");
}
fn character_setup ( mut state : ResMut < State < MyStates > > , mut asset_keys : ResMut < AssetKeys > , mut show_background : ResMut < ShowBackground > , mouse_input : Res < Input < MouseButton > > , keyboard_input : Res < Input < KeyCode > > , ) { if mouse_input . just_pressed ( MouseButton :: Left ) { // Most of the time you don't want to do this manually, // but load dynamic asset collections from a file. // See the `dynamic_asset_ron` example asset_keys . register_asset ( " " , DynamicAsset :: File { path : " " . to_owned ( ) , } , ) ; } else if mouse_input . just_pressed ( MouseButton :: Right ) { asset_keys . register_asset ( " " , DynamicAsset :: File { path : " " . to_owned ( ) , } , ) ; } else if keyboard_input . just_pressed ( KeyCode :: B ) { show_background . 0 = ! show_background . 0 ; return ; } else { return ; } if show_background . 0 { asset_keys . register_asset ( " " , DynamicAsset :: File { path : " " . to_owned ( ) , } , ) ; } state . set ( MyStates :: AssetLoading ) . expect ( " " ) ; }
This system decides which file to load as the character sprite based on some player input
This system decides which file to load as the character sprite based on some player input
state
ResMut<State<MyStates>>
asset_keys
ResMut<AssetKeys>
show_background
ResMut<ShowBackground>
mouse_input
Res<Input<MouseButton>>
keyboard_input
Res<Input<KeyCode>>