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
@ -14,21 +14,13 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, States)]
|
||||||
enum AppState {
|
enum AppState {
|
||||||
#[default]
|
#[default]
|
||||||
Setup,
|
Setup,
|
||||||
Finished,
|
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)]
|
#[derive(Resource, Default)]
|
||||||
struct RpgSpriteHandles {
|
struct RpgSpriteHandles {
|
||||||
handles: Vec<HandleUntyped>,
|
handles: Vec<HandleUntyped>,
|
||||||
|
@ -11,21 +11,13 @@
|
|||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash)]
|
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash, States)]
|
||||||
enum AppState {
|
enum AppState {
|
||||||
#[default]
|
#[default]
|
||||||
MainMenu,
|
MainMenu,
|
||||||
InGame,
|
InGame,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl States for AppState {
|
|
||||||
type Iter = std::array::IntoIter<AppState, 2>;
|
|
||||||
|
|
||||||
fn variants() -> Self::Iter {
|
|
||||||
[AppState::MainMenu, AppState::InGame].into_iter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct TextToPrint(String);
|
struct TextToPrint(String);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user