From 7971574fa45d5b21a633cd90d27c0fc59c6adc06 Mon Sep 17 00:00:00 2001 From: Mizu <5565979+l4desu-mizu@users.noreply.github.com> Date: Sun, 31 Oct 2021 02:09:03 +0100 Subject: [PATCH] update transforms examples with changes from main * use derive component for used components --- examples/transforms/global_vs_local_translation.rs | 10 +++++++++- examples/transforms/rotation.rs | 1 + examples/transforms/scale.rs | 1 + examples/transforms/transform.rs | 2 ++ examples/transforms/translation.rs | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/transforms/global_vs_local_translation.rs b/examples/transforms/global_vs_local_translation.rs index 14a45f195eee0b..99fc30aad33357 100644 --- a/examples/transforms/global_vs_local_translation.rs +++ b/examples/transforms/global_vs_local_translation.rs @@ -1,15 +1,23 @@ use bevy::prelude::*; // Define a marker for entities that should be changed via their global transform. +#[derive(Component)] struct ChangeGlobal; + // Define a marker for entities that should be changed via their local transform. +#[derive(Component)] struct ChangeLocal; + // Define a marker for entities that should move. +#[derive(Component)] struct Move; + // Define a resource for the current movement direction; -#[derive(Default)] +#[derive(Default, Component)] struct Direction(Vec3); + // Define component to decide when an entity should be ignored by the movement systems. +#[derive(Component)] struct ToggledBy(KeyCode); fn main() { diff --git a/examples/transforms/rotation.rs b/examples/transforms/rotation.rs index c66d456a3bbb22..4afa84e417852c 100644 --- a/examples/transforms/rotation.rs +++ b/examples/transforms/rotation.rs @@ -5,6 +5,7 @@ use std::f32::consts::PI; const FULL_TURN: f32 = 2.0 * PI; // Define a component to designate a rotation speed to an entity. +#[derive(Component)] struct Rotatable { speed: f32, } diff --git a/examples/transforms/scale.rs b/examples/transforms/scale.rs index 1add6eca58cedf..09e6a265f28ff7 100644 --- a/examples/transforms/scale.rs +++ b/examples/transforms/scale.rs @@ -3,6 +3,7 @@ use bevy::prelude::*; use std::f32::consts::PI; // Define a component to keep information for the scaled object. +#[derive(Component)] struct Scaling { scale_direction: Vec3, scale_speed: f32, diff --git a/examples/transforms/transform.rs b/examples/transforms/transform.rs index f69142f17e24f6..e35f43445cbbb8 100644 --- a/examples/transforms/transform.rs +++ b/examples/transforms/transform.rs @@ -3,6 +3,7 @@ use bevy::prelude::*; use std::f32::consts::PI; // A struct for additional data of for a moving cube. +#[derive(Component)] struct CubeState { start_pos: Vec3, move_speed: f32, @@ -11,6 +12,7 @@ struct CubeState { // A struct adding information to a scalable entity, // that will be stationary at the center of the scene. +#[derive(Component)] struct Center { max_size: f32, min_size: f32, diff --git a/examples/transforms/translation.rs b/examples/transforms/translation.rs index 2fdccf26c0ae0c..e61dc76f25682a 100644 --- a/examples/transforms/translation.rs +++ b/examples/transforms/translation.rs @@ -2,6 +2,7 @@ use bevy::prelude::*; // Define a struct to keep some information about our entity. // Here it's an arbitrary movement speed, the spawn location, and a maximum distance from it. +#[derive(Component)] struct Movable { spawn: Vec3, max_distance: f32,