Vector2 for position and size on PositionComponent

This commit is contained in:
Lukas Klingsbo
2020-09-24 23:35:36 +02:00
parent 1625ff568b
commit f97f20ab73
33 changed files with 194 additions and 229 deletions

View File

@ -12,16 +12,14 @@ class Sprite {
Sprite(
String fileName, {
double x = 0.0,
double y = 0.0,
double width,
double height,
Vector2 position,
Vector2 size,
}) {
position ??= Vector2.zero();
Flame.images.load(fileName).then((img) {
width ??= img.width.toDouble();
height ??= img.height.toDouble();
size ??= Vector2(img.width.toDouble(), img.height.toDouble());
image = img;
src = Rect.fromLTWH(x, y, width, height);
src = position.toPositionedRect(size);
});
}
@ -100,7 +98,7 @@ class Sprite {
return;
}
size ??= this.size;
renderRect(canvas, p.toRect(size), overridePaint: overridePaint);
renderRect(canvas, p.toPositionedRect(size), overridePaint: overridePaint);
}
void render(