@@ -40,46 +40,45 @@ fn click_spawn_circle(
4040) {
4141 use interpolate:: sprite_color;
4242 let circle_filled_image = asset_server. load ( "circle_filled.png" ) ;
43- if let Some ( coord) = coord. 0 {
44- if key. just_pressed ( MouseButton :: Left )
45- || key. pressed ( MouseButton :: Right )
46- {
47- let start = Vec3 :: new ( coord. x , coord. y , 1. ) ;
48- let end = Vec3 :: new ( 0. , 0. , 0. ) ;
49- let transform = Transform :: from_translation ( start) ;
50- let circle = AnimationTarget . into_target ( ) ;
51- let mut circle_transform = circle. transform_state ( transform) ;
52- commands
53- . spawn ( (
54- Sprite {
55- image : circle_filled_image,
56- ..default ( )
57- } ,
58- transform,
59- AnimationTarget ,
60- ) )
61- . animation ( )
62- . insert ( parallel ( (
63- tween (
64- secs ( 2. ) ,
65- EaseKind :: ExponentialOut ,
66- circle_transform. translation_to ( end) ,
67- ) ,
68- tween (
69- secs ( 1. ) ,
70- EaseKind :: BackIn ,
71- circle_transform. scale_to ( Vec3 :: ZERO ) ,
72- ) ,
73- tween (
74- secs ( 1. ) ,
75- EaseKind :: Linear ,
76- circle. with ( sprite_color (
77- into_color ( WHITE ) ,
78- into_color ( DEEP_PINK ) ,
79- ) ) ,
80- ) ,
81- ) ) ) ;
82- }
43+ if let Some ( coord) = coord. 0
44+ && ( key. just_pressed ( MouseButton :: Left )
45+ || key. pressed ( MouseButton :: Right ) )
46+ {
47+ let start = Vec3 :: new ( coord. x , coord. y , 1. ) ;
48+ let end = Vec3 :: new ( 0. , 0. , 0. ) ;
49+ let transform = Transform :: from_translation ( start) ;
50+ let circle = AnimationTarget . into_target ( ) ;
51+ let mut circle_transform = circle. transform_state ( transform) ;
52+ commands
53+ . spawn ( (
54+ Sprite {
55+ image : circle_filled_image,
56+ ..default ( )
57+ } ,
58+ transform,
59+ AnimationTarget ,
60+ ) )
61+ . animation ( )
62+ . insert ( parallel ( (
63+ tween (
64+ secs ( 2. ) ,
65+ EaseKind :: ExponentialOut ,
66+ circle_transform. translation_to ( end) ,
67+ ) ,
68+ tween (
69+ secs ( 1. ) ,
70+ EaseKind :: BackIn ,
71+ circle_transform. scale_to ( Vec3 :: ZERO ) ,
72+ ) ,
73+ tween (
74+ secs ( 1. ) ,
75+ EaseKind :: Linear ,
76+ circle. with ( sprite_color (
77+ into_color ( WHITE ) ,
78+ into_color ( DEEP_PINK ) ,
79+ ) ) ,
80+ ) ,
81+ ) ) ) ;
8382 }
8483}
8584
0 commit comments