docs: Update input examples to use RectangleComponent where sensible (#3745)

Update input examples to use `RectangleComponent` where sensible.

Minor simplification as suggested by @spydon on
https://github.com/flame-engine/flame/pull/3741
This commit is contained in:
Luan Nico
2025-10-06 09:49:18 -07:00
committed by GitHub
parent 46bd385675
commit 8a73111f5f
3 changed files with 9 additions and 13 deletions

View File

@ -32,7 +32,7 @@ class HoverCallbacksWorld extends World with TapCallbacks {
}
}
class HoverSquare extends PositionComponent with HoverCallbacks {
class HoverSquare extends RectangleComponent with HoverCallbacks {
static final Paint _white = Paint()..color = const Color(0xFFFFFFFF);
static final Paint _grey = Paint()..color = const Color(0xFFA5A5A5);
@ -44,7 +44,5 @@ class HoverSquare extends PositionComponent with HoverCallbacks {
);
@override
void render(Canvas canvas) {
canvas.drawRect(size.toRect(), isHovered ? _grey : _white);
}
Paint get paint => isHovered ? _grey : _white;
}