make the examples use the States derive macro (#8289)

# Objective
Some examples still manually implement the States trait, even though
manual implementation is no longer needed as there is now the derive
macro for that.

---------

Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
This commit is contained in:
Natalia 2023-04-02 11:25:47 +07:00 committed by GitHub
parent 9079f6d976
commit 7a9e77c79c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 18 deletions

View file

@ -14,21 +14,13 @@ fn main() {
.run();
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, States)]
enum AppState {
#[default]
Setup,
Finished,
}
impl States for AppState {
type Iter = std::array::IntoIter<AppState, 2>;
fn variants() -> Self::Iter {
[AppState::Setup, AppState::Finished].into_iter()
}
}
#[derive(Resource, Default)]
struct RpgSpriteHandles {
handles: Vec<HandleUntyped>,

View file

@ -11,21 +11,13 @@
use bevy::prelude::*;
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash)]
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash, States)]
enum AppState {
#[default]
MainMenu,
InGame,
}
impl States for AppState {
type Iter = std::array::IntoIter<AppState, 2>;
fn variants() -> Self::Iter {
[AppState::MainMenu, AppState::InGame].into_iter()
}
}
#[derive(Component)]
struct TextToPrint(String);