mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
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:
parent
9079f6d976
commit
7a9e77c79c
2 changed files with 2 additions and 18 deletions
|
@ -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>,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue