1+ use std:: time:: Duration ;
2+
13use bevy:: prelude:: * ;
4+
25use bevy_tweening:: { lens:: * , * } ;
3- use std:: time:: Duration ;
46
57fn main ( ) {
68 App :: default ( )
@@ -107,19 +109,31 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
107109 Vec3 :: new ( margin, screen_y - margin, 0. ) ,
108110 Vec3 :: new ( margin, margin, 0. ) ,
109111 ] ;
110- // Build a sequence from an iterator over a Tweenable (here, a Tween<Transform>)
112+ // Build a sequence from an iterator over a Tweenable (here, a
113+ // Tracks<Transform>)
111114 let seq = Sequence :: new ( dests. windows ( 2 ) . enumerate ( ) . map ( |( index, pair) | {
112- Tween :: new (
113- EaseFunction :: QuadraticInOut ,
114- TweeningType :: Once ,
115- Duration :: from_secs ( 1 ) ,
116- TransformPositionLens {
117- start : pair[ 0 ] - center,
118- end : pair[ 1 ] - center,
119- } ,
120- )
121- // Get an event after each segment
122- . with_completed_event ( index as u64 )
115+ Tracks :: new ( [
116+ Tween :: new (
117+ EaseFunction :: QuadraticInOut ,
118+ Duration :: from_millis ( 250 ) ,
119+ TransformRotateZLens {
120+ start : 0. ,
121+ end : 180_f32 . to_radians ( ) ,
122+ } ,
123+ )
124+ . with_repeat_count ( RepeatCount :: Finite ( 4 ) )
125+ . with_repeat_strategy ( RepeatStrategy :: MirroredRepeat ) ,
126+ Tween :: new (
127+ EaseFunction :: QuadraticInOut ,
128+ Duration :: from_secs ( 1 ) ,
129+ TransformPositionLens {
130+ start : pair[ 0 ] - center,
131+ end : pair[ 1 ] - center,
132+ } ,
133+ )
134+ // Get an event after each segment
135+ . with_completed_event ( index as u64 ) ,
136+ ] )
123137 } ) ) ;
124138
125139 commands
@@ -138,7 +152,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
138152 // scaling size at the same time.
139153 let tween_move = Tween :: new (
140154 EaseFunction :: QuadraticInOut ,
141- TweeningType :: Once ,
142155 Duration :: from_secs ( 1 ) ,
143156 TransformPositionLens {
144157 start : Vec3 :: new ( -200. , 100. , 0. ) ,
@@ -148,7 +161,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
148161 . with_completed_event ( 99 ) ; // Get an event once move completed
149162 let tween_rotate = Tween :: new (
150163 EaseFunction :: QuadraticInOut ,
151- TweeningType :: Once ,
152164 Duration :: from_secs ( 1 ) ,
153165 TransformRotationLens {
154166 start : Quat :: IDENTITY ,
@@ -157,7 +169,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
157169 ) ;
158170 let tween_scale = Tween :: new (
159171 EaseFunction :: QuadraticInOut ,
160- TweeningType :: Once ,
161172 Duration :: from_secs ( 1 ) ,
162173 TransformScaleLens {
163174 start : Vec3 :: ONE ,
0 commit comments