mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-01 01:18:38 +08:00 
			
		
		
		
	feat(effects): Added SineEffectController (#1262)
An effect controller that represents a single period of the sine function. Use this to create natural-looking harmonic oscillations. Two perpendicular move effects governed by SineEffectControllers with different periods, will create a [Lissajous curve].
This commit is contained in:
		| @ -8,10 +8,15 @@ class EffectControllersExample extends FlameGame { | ||||
|   static const description = ''' | ||||
|     This page demonstrates application of various non-standard effect  | ||||
|     controllers. | ||||
|      | ||||
|  | ||||
|     The first white square has a ZigzagEffectController with period 1. The | ||||
|     orange square next to it has two move effects, each with a  | ||||
|     orange square next to it has two move effects, each with a | ||||
|     ZigzagEffectController. | ||||
|  | ||||
|     The lime square has a SineEffectController with the same period of 1s. The | ||||
|     violet square next to it has two move effects, each with a | ||||
|     SineEffectController with periods, but one of the effects is slightly  | ||||
|     delayed. | ||||
|   '''; | ||||
|  | ||||
|   @override | ||||
| @ -44,5 +49,35 @@ class EffectControllersExample extends FlameGame { | ||||
|           ), | ||||
|         ]), | ||||
|     ); | ||||
|  | ||||
|     add( | ||||
|       RectangleComponent.square( | ||||
|         position: Vector2(140, 50), | ||||
|         size: 20, | ||||
|         paint: Paint()..color = const Color(0xffbeff63), | ||||
|       )..add( | ||||
|           MoveEffect.by( | ||||
|             Vector2(0, 20), | ||||
|             InfiniteEffectController(SineEffectController(period: 1)), | ||||
|           ), | ||||
|         ), | ||||
|     ); | ||||
|     add( | ||||
|       RectangleComponent.square( | ||||
|         position: Vector2(190, 50), | ||||
|         size: 10, | ||||
|         paint: Paint()..color = const Color(0xffb663ff), | ||||
|       )..addAll([ | ||||
|           MoveEffect.by( | ||||
|             Vector2(0, 20), | ||||
|             InfiniteEffectController(SineEffectController(period: 1)) | ||||
|               ..advance(0.25), | ||||
|           ), | ||||
|           MoveEffect.by( | ||||
|             Vector2(10, 0), | ||||
|             InfiniteEffectController(SineEffectController(period: 1)), | ||||
|           ), | ||||
|         ]), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Pasha Stetsenko
					Pasha Stetsenko