mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 03:15:43 +08:00
Part 3: Great Composed Component Refactor
This commit is contained in:
@ -23,14 +23,17 @@ class Palette {
|
||||
|
||||
class Square extends PositionComponent with HasGameRef<MyGame> {
|
||||
static const SPEED = 0.25;
|
||||
static Paint white = Palette.white.paint;
|
||||
static Paint red = Palette.red.paint;
|
||||
static Paint blue = Palette.blue.paint;
|
||||
|
||||
@override
|
||||
void render(Canvas c) {
|
||||
prepareCanvas(c);
|
||||
super.render(c);
|
||||
|
||||
c.drawRect(Rect.fromLTWH(0, 0, width, height), Palette.white.paint);
|
||||
c.drawRect(const Rect.fromLTWH(0, 0, 3, 3), Palette.red.paint);
|
||||
c.drawRect(Rect.fromLTWH(width / 2, height / 2, 3, 3), Palette.blue.paint);
|
||||
c.drawRect(toZeroRect(), white);
|
||||
c.drawRect(const Rect.fromLTWH(0, 0, 3, 3), red);
|
||||
c.drawRect(Rect.fromLTWH(width / 2, height / 2, 3, 3), blue);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user