Expand description
Module containing some basic built-in interpolator
Plugins:
Built-in interpolators:
§Your own Interpolator
There are a few amount of built-in interpolator because this crate only
implemented the most common ones such as Translation
or
SpriteColor
and some more.
For others, you must implement your own!
Let’s say you’ve created some custom component and you want to interpolate it:
use bevy::prelude::*;
#[derive(Component)]
struct Foo(f32);
You’ll need to create a specific interpolator for this component by:
use bevy_tween::prelude::*;
// First we define an interpolator type for `Foo`.
struct InterpolateFoo {
start: f32,
end: f32,
}
impl Interpolator for InterpolateFoo {
// We define the asscioate type `Item` as the `Foo` component
type Item = Foo;
// Then we define how we want to interpolate `Foo`
fn interpolate(&self, item: &mut Self::Item, value: f32, _previous_value: f32) {
// Usually if the type already have the `.lerp` function provided
// by the `FloatExt` trait then we can use just that
item.0 = self.start.lerp(self.end, value);
}
}
If you’ve created a custom interpolator or a custom component/asset/resource, you may want to register some systems.
While it’s recommended to use the Interpolator
trait, it’s not required
to make your interpolators work in this crate. the Interpolator
as of
currently is only used for registering built-in simple interpolator systems
such as component_tween_system
, resource_tween_system
, and
asset_tween_system
. Its next use is being object-safe for dynamic interpolator.
If you need interpolators with more specific or complex system param, you have to define your own system!
Structs§
- AngleZ
Interpolator
forTransform
’s rotation at Z axis. Usually used for 2D rotation.- Default
DynInterpolators Plugin - Default dynamic interpolators
- Default
Interpolators Plugin - Default interpolators
- Rotation
Interpolator
forTransform
’s rotation using theQuat::slerp
function.- Scale
Interpolator
forTransform
’s scale- Sprite
Color bevy_sprite
Interpolator
forSprite
’s color- Translation
Interpolator
forTransform
’s translation.
Traits§
- Interpolator
Interpolator
is used to specify how to interpolate anSelf::Item
by the implementor.
Functions§
- angle_z
- Constructor for
AngleZ
- angle_
z_ by - Constructor for
AngleZ
that’s relative to previous value using currying. - angle_
z_ delta_ by - Constructor for
AngleZ
that’s relative to previous value Since this is a delta tween, it can happen with other ongoing tweens of that type - angle_
z_ to - Constructor for
AngleZ
that’s relative to previous value using currying. - background_
color bevy_ui
- Constructor for
BackgroundColor
- background_
color_ delta_ to bevy_ui
- Constructor for delta
BackgroundColor
- background_
color_ to bevy_ui
- Constructor for
BackgroundColor
that’s relative to previous value using currying. - border_
color bevy_ui
- Constructor for
BorderColor
- border_
color_ delta_ to bevy_ui
- Constructor for
BorderColor
that’s relative to previous value using currying. - border_
color_ to bevy_ui
- Constructor for
BorderColor
that’s relative to previous value using currying. - closure
- Create boxed closure in order to be used with dynamic
Interpolator
- color_
material bevy_sprite
- Constructor for
ColorMaterial
- color_
material_ delta_ to bevy_sprite
- Constructor for delta
ColorMaterial
- color_
material_ to bevy_sprite
- Constructor for
ColorMaterial
that’s relative to previous value using currying. - rotation
- Constructor for
Rotation
- rotation_
by - Constructor for
Rotation
that’s relative to previous value using currying. - rotation_
delta_ by - Constructor for
Rotation
that’s relative to previous value Since this is a delta tween, it can happen with other ongoing tweens of that type - rotation_
to - Constructor for
Rotation
that’s relative to previous value using currying. - scale
- Constructor for
Scale
- scale_
by - Constructor for
Scale
that’s relative to previous value using currying. - scale_
delta_ by - Constructor for
Scale
that’s relative to previous value Since this is a delta tween, it can happen with other ongoing tweens of that type - scale_
to - Constructor for
Scale
that’s relative to previous value using currying. - sprite_
color bevy_sprite
- Constructor for
SpriteColor
- sprite_
color_ delta_ to bevy_sprite
- Constructor for delta
SpriteColor
- sprite_
color_ to bevy_sprite
- Constructor for
SpriteColor
that’s relative to previous value using currying. - translation
- Constructor for
Translation
- translation_
by - Constructor for
Translation
that’s relative to previous value using currying. - translation_
delta_ by - Constructor for
Translation
that’s relative to previous value Since this is a delta tween, it can happen with other ongoing tweens of that type - translation_
to - Constructor for
Translation
that’s relative to previous value using currying.
Type Aliases§
- Boxed
Interpolator - Alias for an
Interpolator
as a boxed trait object. - Current
Value - A marker type for the tweens current value, for ease of closure readability
- Previous
Value - A marker type for the tweens previous value, for ease of closure readability