From 48d1c4edeebf5e1a2f2daf0adbebddce2d34c74a Mon Sep 17 00:00:00 2001 From: Multirious Date: Sat, 8 Jun 2024 23:42:28 +0700 Subject: [PATCH] Update docs --- src/combinator.rs | 2 +- src/lib.rs | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/combinator.rs b/src/combinator.rs index c4fbdae..35e50e2 100644 --- a/src/combinator.rs +++ b/src/combinator.rs @@ -1,4 +1,4 @@ -//! Combinators for tweens using this crate's default tweener +//! Combinator framework use std::time::Duration; diff --git a/src/lib.rs b/src/lib.rs index 94afa3f..fd9c483 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -219,6 +219,66 @@ //! .repeat(Repeat::Infinitely) //! .insert(my_animation(&mut sprite_color, Duration::from_secs(1))); //! ``` +//! There are more combinators you can use. Check them out in the [`combinator`] moduel +//! +//! ## Animator as a child +//! You can spawn animator as a child if you want +//! ``` +#![doc = utils::doc_test_boilerplate!()] +//! # let mut sprite_commands = commands.spawn(SpriteBundle { +//! # sprite: Sprite { +//! # custom_size: Some(Vec2::new(50., 50.)), +//! # ..Default::default() +//! # }, +//! # ..Default::default() +//! # }); +//! use bevy_tween::{ +//! interpolate::sprite_color, +//! combinator::{tween, sequence} +//! }; +//! +//! let sprite = sprite_commands.id().into_target(); +//! sprite_commands.with_children(|c| { +//! c.animation().insert(sequence(( +//! tween( +//! Duration::from_secs(1), +//! EaseFunction::QuadraticOut, +//! sprite.with(sprite_color(Color::WHITE, Color::RED)) +//! ), +//! tween( +//! Duration::from_secs(1), +//! EaseFunction::QuadraticIn, +//! sprite.with(sprite_color(Color::RED, Color::WHITE)) +//! ), +//! ))); +//! }); +//! ``` +//! +//! ## [`AnimationTarget`] +//! [`AnimationTarget`] can be used for automatic target searching. +//! ```no_run +#![doc = utils::doc_test_boilerplate!()] +//! # let mut sprite_commands = commands.spawn(SpriteBundle { +//! # sprite: Sprite { +//! # custom_size: Some(Vec2::new(50., 50.)), +//! # ..Default::default() +//! # }, +//! # ..Default::default() +//! # }); +//! use bevy_tween::{ +//! interpolate::sprite_color, +//! combinator::tween, +//! tween::AnimationTarget, +//! }; +//! +//! let sprite = AnimationTarget.into_target() // which returns TargetComponent::Marker; +//! sprite_commands.insert(AnimationTarget); +//! sprite_commands.animation().insert_tween_here( +//! Duration::from_secs(1), +//! EaseFunction::QuadraticOut, +//! sprite.with(sprite_color(Color::WHITE, Color::RED)) +//! ); +//! ``` //! //! ## Custom interpolator //!