mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
Abstracting text API to enable custom renderers (#772)
* Abstracting text API to enable custom renderers * Addressing comments * Lint * Update doc/text.md Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com> * Adding dartdoc about TextRenderer Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
This commit is contained in:
@ -4,13 +4,17 @@ import 'package:flame/timer.dart';
|
||||
import 'package:flame/gestures.dart';
|
||||
|
||||
class RenderedTimeComponent extends TimerComponent {
|
||||
final TextConfig textConfig = TextConfig(color: const Color(0xFFFFFFFF));
|
||||
final TextPaint textPaint = TextPaint(
|
||||
config: const TextPaintConfig(
|
||||
color: Color(0xFFFFFFFF),
|
||||
),
|
||||
);
|
||||
|
||||
RenderedTimeComponent(Timer timer) : super(timer);
|
||||
|
||||
@override
|
||||
void render(Canvas canvas) {
|
||||
textConfig.render(
|
||||
textPaint.render(
|
||||
canvas,
|
||||
'Elapsed time: ${timer.current}',
|
||||
Vector2(10, 150),
|
||||
|
||||
Reference in New Issue
Block a user