mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 03:15:43 +08:00
* Added flame_oxygen * Reworked structure * Added components and example * Added particle support * Updated code * Update example * Fixed mistake * Update * Updated documentation * Added system documentation * Fixed line length * Added most components docs * Docs done? * Update doc/oxygen.md Co-authored-by: Erick <erickzanardoo@gmail.com> * Added GameRef * Fixed GameRef * Reworked library to not use part system * Added GameRef docs * Removed library line * Updated CHANGELOG * Added License * Fixed linting problem * Update packages/flame_oxygen/example/lib/main.dart Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com> * Update after review from spydon * Added flipping * Fixed CI/CD * Fix * Update * Update doc/oxygen.md Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com> Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com> Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com>
47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
import 'package:flame/game.dart';
|
|
import 'package:flame_oxygen/flame_oxygen.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../component/timer_component.dart';
|
|
|
|
class KawabungaSystem extends BaseSystem with UpdateSystem {
|
|
@override
|
|
List<Filter<Component>> get filters => [
|
|
Has<TextComponent>(),
|
|
Has<TimerComponent>(),
|
|
];
|
|
|
|
@override
|
|
void renderEntity(Canvas canvas, Entity entity) {
|
|
final timer = entity.get<TimerComponent>()!;
|
|
final textComponent = entity.get<TextComponent>()!;
|
|
final textRenderer = TextPaint(
|
|
config: textComponent.config.withColor(
|
|
textComponent.config.color.withOpacity(1 - timer.percentage),
|
|
),
|
|
);
|
|
|
|
textRenderer.render(
|
|
canvas,
|
|
textComponent.text,
|
|
Vector2.zero(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void update(double delta) {
|
|
for (final entity in entities) {
|
|
final textComponent = entity.get<TextComponent>()!;
|
|
final size = entity.get<SizeComponent>()!.size;
|
|
final textRenderer = TextPaint(config: textComponent.config);
|
|
size.setFrom(textRenderer.measureText(textComponent.text));
|
|
|
|
final timer = entity.get<TimerComponent>()!;
|
|
timer.timePassed = timer.timePassed + delta;
|
|
if (timer.done) {
|
|
entity.dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|