Skip to content

Instantly share code, notes, and snippets.

@erickzanardo
Created June 14, 2022 17:21
Show Gist options
  • Save erickzanardo/e1365aeb1fd29d27039cd4abb952d575 to your computer and use it in GitHub Desktop.
Save erickzanardo/e1365aeb1fd29d27039cd4abb952d575 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flame/effects.dart';
void main() {
const shadowSize = 10.0;
runApp(
GameWidget(
game: FlameGame(
children: [
PositionComponent(
position: Vector2(200, 200),
children: [
RectangleComponent(
size: Vector2(50 + shadowSize, 50),
position: Vector2(-shadowSize, 0),
paint: Paint()..color = Colors.blue,
anchor: Anchor.center,
children: [
SequenceEffect(
[
ColorEffect(
const Color(0xFF000000),
const Offset(0.0, 0.8),
EffectController(duration: 1),
),
ColorEffect(
const Color(0xFF000000),
const Offset(0.8, 0),
EffectController(duration: 1),
),
],
infinite: true,
),
SequenceEffect(
[
ScaleEffect.to(
Vector2(.2, 1),
EffectController(duration: .5),
),
ScaleEffect.to(
Vector2(-1, 1),
EffectController(duration: .5),
),
ScaleEffect.to(
Vector2(.2, 1),
EffectController(duration: .5),
),
ScaleEffect.to(
Vector2(1, 1),
EffectController(duration: .5),
),
],
infinite: true,
),
SequenceEffect(
[
MoveEffect.to(
Vector2(shadowSize, 0),
EffectController(duration: 1),
),
MoveEffect.to(
Vector2(-shadowSize, 0),
EffectController(duration: 1),
),
],
infinite: true,
),
],
),
RectangleComponent(
size: Vector2.all(50),
paint: Paint()..color = Colors.blue,
anchor: Anchor.center,
children: [
SequenceEffect(
[
ScaleEffect.to(
Vector2(.2, 1),
EffectController(duration: .5),
),
ScaleEffect.to(
Vector2(-1, 1),
EffectController(duration: .5),
),
ScaleEffect.to(
Vector2(.2, 1),
EffectController(duration: .5),
),
ScaleEffect.to(
Vector2(1, 1),
EffectController(duration: .5),
),
],
infinite: true,
),
SequenceEffect(
[
ColorEffect(
const Color(0xFF000000),
const Offset(0.8, 0),
EffectController(duration: 1),
),
ColorEffect(
const Color(0xFF000000),
const Offset(0.0, 0.8),
EffectController(duration: 1),
),
],
infinite: true,
),
],
),
],
),
],
),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment