Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use bevy::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.insert_resource(WindowDescriptor {
title: "TransformRotationLens".to_string(),
width: 1400.,
height: 600.,
vsync: true,
..Default::default()
})
.add_plugins(DefaultPlugins)
.add_plugin(bevy_tweening::TweeningPlugin)
.add_startup_system(setup)
.run();
Ok(())
}
fn setup(mut commands: Commands) {
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
let size = 80.;
let spacing = 1.6;
let screen_x = 570.;
let screen_y = 150.;
let mut x = -screen_x;
let mut y = screen_y;
for ease_function in &[
bevy_tweening::EaseFunction::QuadraticIn,
bevy_tweening::EaseFunction::QuadraticOut,
bevy_tweening::EaseFunction::QuadraticInOut,
bevy_tweening::EaseFunction::CubicIn,
bevy_tweening::EaseFunction::CubicOut,
bevy_tweening::EaseFunction::CubicInOut,
bevy_tweening::EaseFunction::QuarticIn,
bevy_tweening::EaseFunction::QuarticOut,
bevy_tweening::EaseFunction::QuarticInOut,
bevy_tweening::EaseFunction::QuinticIn,
bevy_tweening::EaseFunction::QuinticOut,
bevy_tweening::EaseFunction::QuinticInOut,
bevy_tweening::EaseFunction::SineIn,
bevy_tweening::EaseFunction::SineOut,
bevy_tweening::EaseFunction::SineInOut,
bevy_tweening::EaseFunction::CircularIn,
bevy_tweening::EaseFunction::CircularOut,
bevy_tweening::EaseFunction::CircularInOut,
bevy_tweening::EaseFunction::ExponentialIn,
bevy_tweening::EaseFunction::ExponentialOut,
bevy_tweening::EaseFunction::ExponentialInOut,
bevy_tweening::EaseFunction::ElasticIn,
bevy_tweening::EaseFunction::ElasticOut,
bevy_tweening::EaseFunction::ElasticInOut,
bevy_tweening::EaseFunction::BackIn,
bevy_tweening::EaseFunction::BackOut,
bevy_tweening::EaseFunction::BackInOut,
bevy_tweening::EaseFunction::BounceIn,
bevy_tweening::EaseFunction::BounceOut,
bevy_tweening::EaseFunction::BounceInOut,
] {
commands
.spawn_bundle((
Transform::from_translation(Vec3::new(x, y, 0.)),
GlobalTransform::default(),
))
.with_children(|parent| {
parent
.spawn_bundle(SpriteBundle {
sprite: Sprite {
color: Color::RED,
custom_size: Some(Vec2::new(size, size)),
..Default::default()
},
..Default::default()
})
.insert(bevy_tweening::Animator::new(
*ease_function,
bevy_tweening::TweeningType::PingPong,
std::time::Duration::from_secs(1),
bevy_tweening::TransformRotationLens {
start: Quat::IDENTITY,
end: Quat::from_axis_angle(Vec3::Z, std::f32::consts::PI / 2.),
},
));
});
y -= size * spacing;
if y < -screen_y {
x += size * spacing;
y = screen_y;
}
}
}