mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
TextPaint to use TextStyle instead of TextPaintConfig (#1086)
* `TextPaint` to use `TextStyle` instead of `TextPaintConfig` * Update packages/flame/lib/src/text.dart Co-authored-by: Pasha Stetsenko <stpasha@google.com> * Removed BaseTextConfig and TextPaintConfig * Update text docs * Apply suggestions from code review Co-authored-by: Erick <erickzanardoo@gmail.com> * Remove generics * Update TextBoxExample * Update text examples variable names * Fix TextPaint in collision_detection example Co-authored-by: Pasha Stetsenko <stpasha@google.com> Co-authored-by: Erick <erickzanardoo@gmail.com>
This commit is contained in:
@ -8,17 +8,11 @@ class DebugSystem extends BaseSystem {
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
final textPainter = TextPaint(
|
||||
config: const TextPaintConfig(
|
||||
color: Colors.green,
|
||||
fontSize: 10,
|
||||
),
|
||||
style: const TextStyle(color: Colors.green, fontSize: 10),
|
||||
);
|
||||
|
||||
final statusPainter = TextPaint(
|
||||
config: const TextPaintConfig(
|
||||
color: Colors.green,
|
||||
fontSize: 16,
|
||||
),
|
||||
style: const TextStyle(color: Colors.green, fontSize: 16),
|
||||
);
|
||||
|
||||
@override
|
||||
|
||||
@ -16,8 +16,8 @@ class KawabungaSystem extends BaseSystem with UpdateSystem {
|
||||
final timer = entity.get<TimerComponent>()!;
|
||||
final textComponent = entity.get<TextComponent>()!;
|
||||
final textRenderer = TextPaint(
|
||||
config: textComponent.config.withColor(
|
||||
textComponent.config.color.withOpacity(1 - timer.percentage),
|
||||
style: textComponent.style.copyWith(
|
||||
color: textComponent.style.color!.withOpacity(1 - timer.percentage),
|
||||
),
|
||||
);
|
||||
|
||||
@ -33,7 +33,7 @@ class KawabungaSystem extends BaseSystem with UpdateSystem {
|
||||
for (final entity in entities) {
|
||||
final textComponent = entity.get<TextComponent>()!;
|
||||
final size = entity.get<SizeComponent>()!.size;
|
||||
final textRenderer = TextPaint(config: textComponent.config);
|
||||
final textRenderer = TextPaint(style: textComponent.style);
|
||||
size.setFrom(textRenderer.measureText(textComponent.text));
|
||||
|
||||
final timer = entity.get<TimerComponent>()!;
|
||||
|
||||
@ -46,7 +46,7 @@ class MoveSystem extends System with UpdateSystem, GameRef<ExampleGame> {
|
||||
..add<TextComponent, TextInit>(
|
||||
TextInit(
|
||||
'Kawabunga',
|
||||
config: const TextPaintConfig(color: Colors.blue, fontSize: 12),
|
||||
style: const TextStyle(color: Colors.blue, fontSize: 12),
|
||||
),
|
||||
)
|
||||
..add<TimerComponent, double>(3);
|
||||
|
||||
Reference in New Issue
Block a user