设置世界背景颜色
Set world backgroundcolor
如何设置背景颜色?
我尝试在 onLoad 中进行设置:
world.color.setRGB(0,0,255);
我也试过添加一个组件,但我也许有更好的方法:
class Background extends PositionComponent with HasGameRef {
@override
int priority = -1;
late Paint white;
late final Rect hugeRect;
Background() : super(size: Vector2.all(100000));
@override
Future<void> onLoad() async {
white = BasicPalette.blue.paint();
hugeRect = size.toRect();
}
@override
void render(Canvas c) {
c.drawRect(hugeRect, white);
}
}
@override
Color backgroundColor() => const Color(0xFFeeeeee);
如何设置背景颜色?
我尝试在 onLoad 中进行设置:
world.color.setRGB(0,0,255);
我也试过添加一个组件,但我也许有更好的方法:
class Background extends PositionComponent with HasGameRef {
@override
int priority = -1;
late Paint white;
late final Rect hugeRect;
Background() : super(size: Vector2.all(100000));
@override
Future<void> onLoad() async {
white = BasicPalette.blue.paint();
hugeRect = size.toRect();
}
@override
void render(Canvas c) {
c.drawRect(hugeRect, white);
}
}
@override
Color backgroundColor() => const Color(0xFFeeeeee);