Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Multirious committed Jun 8, 2024
1 parent 67d5e8d commit 48d1c4e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/combinator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Combinators for tweens using this crate's default tweener
//! Combinator framework

use std::time::Duration;

Expand Down
60 changes: 60 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
//!
Expand Down

0 comments on commit 48d1c4e

Please sign in to comment.