mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 20:36:31 +08:00
Vector2 for position and size on PositionComponent
This commit is contained in:
@ -3,18 +3,19 @@ import 'package:flame/components/position_component.dart';
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flame/extensions/vector2.dart';
|
||||
|
||||
class Square extends PositionComponent {
|
||||
static final _paint = Paint()..color = const Color(0xFFFFFFFF);
|
||||
|
||||
Square() {
|
||||
width = 100;
|
||||
height = 100;
|
||||
size = Vector2.all(100);
|
||||
anchor = Anchor.center;
|
||||
}
|
||||
|
||||
@override
|
||||
void render(Canvas canvas) {
|
||||
super.render(canvas);
|
||||
canvas.drawRect(toOriginRect(), _paint);
|
||||
canvas.drawRect(size.toRect(), _paint);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user