Module interpolate

Module interpolate 

Source
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 for Transform’s rotation at Z axis. Usually used for 2D rotation.
DefaultDynInterpolatorsPlugin
Default dynamic interpolators
DefaultInterpolatorsPlugin
Default interpolators
Rotation
Interpolator for Transform’s rotation using the Quat::slerp function.
Scale
Interpolator for Transform’s scale
SpriteColorbevy_sprite
Interpolator for Sprite’s color
Translation
Interpolator for Transform’s translation.

Traits§

Interpolator
Interpolator is used to specify how to interpolate an Self::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_colorbevy_ui
Constructor for BackgroundColor
background_color_delta_tobevy_ui
Constructor for delta BackgroundColor
background_color_tobevy_ui
Constructor for BackgroundColor that’s relative to previous value using currying.
border_colorbevy_ui
Constructor for BorderColor
border_color_delta_tobevy_ui
Constructor for BorderColor that’s relative to previous value using currying.
border_color_tobevy_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_materialbevy_sprite
Constructor for ColorMaterial
color_material_delta_tobevy_sprite
Constructor for delta ColorMaterial
color_material_tobevy_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_colorbevy_sprite
Constructor for SpriteColor
sprite_color_delta_tobevy_sprite
Constructor for delta SpriteColor
sprite_color_tobevy_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§

BoxedInterpolator
Alias for an Interpolator as a boxed trait object.
CurrentValue
A marker type for the tweens current value, for ease of closure readability
PreviousValue
A marker type for the tweens previous value, for ease of closure readability