Created
June 16, 2022 17:50
-
-
Save erickzanardo/cca5607f6009c63ad0a1cc912292fa09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
import 'package:flutter/material.dart'; | |
import 'package:flame/components.dart'; | |
import 'package:flame/game.dart'; | |
import 'package:flame/effects.dart'; | |
final tween = Tween<double>(begin: 0, end: 360); | |
final size = Colors.accents.length; | |
double coord(int i) => tween.transform((i + 1) / size) * pi / 180; | |
void main() { | |
const ballSize = 50.0; | |
runApp( | |
GameWidget( | |
game: FlameGame( | |
children: [ | |
PositionComponent( | |
anchor: Anchor.center, | |
position: Vector2(200, 200), | |
children: [ | |
for (var i = 0; i < size; i++) | |
CircleComponent( | |
anchor: Anchor.center, | |
paint: Paint()..color = Colors.accents[i], | |
radius: ballSize / 2, | |
position: Vector2(sin(coord(i)) * 100, cos(coord(i)) * 100), | |
children: [ | |
SequenceEffect( | |
[ | |
MoveEffect.to( | |
Vector2.zero(), | |
CurvedEffectController( | |
1, | |
Curves.easeInCubic, | |
), | |
), | |
MoveEffect.to( | |
Vector2(sin(coord(i)) * 100, cos(coord(i)) * 100), | |
CurvedEffectController( | |
1, | |
Curves.easeInCubic, | |
), | |
), | |
], | |
infinite: true, | |
), | |
SequenceEffect( | |
[ | |
ColorEffect( | |
Colors.white, | |
const Offset(0, 1), | |
CurvedEffectController(1, Curves.easeInCubic), | |
), | |
ColorEffect( | |
Colors.white, | |
const Offset(1, 0), | |
CurvedEffectController(1, Curves.easeInCubic), | |
), | |
], | |
infinite: true, | |
), | |
], | |
), | |
SequenceEffect( | |
[ | |
RotateEffect.to( | |
pi, | |
CurvedEffectController(1, Curves.easeInExpo), | |
), | |
RotateEffect.to( | |
0, | |
CurvedEffectController(1, Curves.easeInExpo), | |
), | |
], | |
infinite: true, | |
), | |
], | |
), | |
], | |
), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment