From 678c0b8c0c3785f1e81ddd53e5d351bad76ae341 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Sat, 1 Jul 2023 07:46:51 -0700 Subject: [PATCH] Simple-ish text typing animation --- bin/text-inspect.rs | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/bin/text-inspect.rs b/bin/text-inspect.rs index 8f65cba..68fc3b4 100644 --- a/bin/text-inspect.rs +++ b/bin/text-inspect.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + use bevy::{diagnostic::FrameTimeDiagnosticsPlugin, prelude::*}; const LOREM: [&str; 5] = [ @@ -24,7 +26,6 @@ fn main() { .add_system(update) .add_system(mouse_cursor) .add_system(play) - .add_system(framerate) .run(); } @@ -92,13 +93,13 @@ fn init_ui(mut commands: Commands) { TextBundle::from_sections(LOREM.iter().map(|§ion| TextSection { value: section.into(), style: TextStyle { - font_size: 50.0, + font_size: 20.0, ..default() }, })) .with_style(Style { max_size: Size { - width: Val::Px(500.), + width: Val::Px(450.), height: Val::Undefined, }, ..default() @@ -137,7 +138,7 @@ fn manage_buttons( let style = TextStyle { font: font.clone(), color: Color::BLACK, - font_size: 18.0, + font_size: 16.0, }; root.spawn(( @@ -178,7 +179,7 @@ fn update( value: c.into(), style: TextStyle { font: font.clone(), - font_size: 50.0, + font_size: 16.0, ..default() }, }) @@ -206,35 +207,26 @@ fn mouse_cursor( fn play( mut texts: Query<&mut Text, (With, With)>, interactions: Query<&Interaction, (Changed, With)>, - mut playing: Local, time: Res