mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 20:13:50 +08:00
address comments
This commit is contained in:
@ -18,6 +18,6 @@ class Square extends PositionComponent {
|
|||||||
@override
|
@override
|
||||||
void render(Canvas canvas) {
|
void render(Canvas canvas) {
|
||||||
super.render(canvas);
|
super.render(canvas);
|
||||||
canvas.drawRect(toZeroRect(), _paint);
|
canvas.drawRect(toOriginRect(), _paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,6 @@ class Square extends PositionComponent {
|
|||||||
@override
|
@override
|
||||||
void render(Canvas canvas) {
|
void render(Canvas canvas) {
|
||||||
super.render(canvas);
|
super.render(canvas);
|
||||||
canvas.drawRect(toZeroRect(), _paint);
|
canvas.drawRect(toOriginRect(), _paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,6 @@ class Square extends PositionComponent {
|
|||||||
@override
|
@override
|
||||||
void render(Canvas canvas) {
|
void render(Canvas canvas) {
|
||||||
super.render(canvas);
|
super.render(canvas);
|
||||||
canvas.drawRect(toZeroRect(), _paint);
|
canvas.drawRect(toOriginRect(), _paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,6 @@ class Square extends PositionComponent {
|
|||||||
@override
|
@override
|
||||||
void render(Canvas canvas) {
|
void render(Canvas canvas) {
|
||||||
super.render(canvas);
|
super.render(canvas);
|
||||||
canvas.drawRect(toZeroRect(), _paint);
|
canvas.drawRect(toOriginRect(), _paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class TapableSquare extends PositionComponent with Tapable {
|
|||||||
@override
|
@override
|
||||||
void render(Canvas canvas) {
|
void render(Canvas canvas) {
|
||||||
super.render(canvas);
|
super.render(canvas);
|
||||||
canvas.drawRect(toZeroRect(), _beenPressed ? _grey : _white);
|
canvas.drawRect(toOriginRect(), _beenPressed ? _grey : _white);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class Ball extends PositionComponent {
|
|||||||
@override
|
@override
|
||||||
void render(Canvas c) {
|
void render(Canvas c) {
|
||||||
super.render(c);
|
super.render(c);
|
||||||
c.drawOval(toZeroRect(), paint);
|
c.drawOval(toOriginRect(), paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class Square extends PositionComponent with HasGameRef<MyGame> {
|
|||||||
void render(Canvas c) {
|
void render(Canvas c) {
|
||||||
super.render(c);
|
super.render(c);
|
||||||
|
|
||||||
c.drawRect(toZeroRect(), white);
|
c.drawRect(toOriginRect(), white);
|
||||||
c.drawRect(const Rect.fromLTWH(0, 0, 3, 3), red);
|
c.drawRect(const Rect.fromLTWH(0, 0, 3, 3), red);
|
||||||
c.drawRect(Rect.fromLTWH(width / 2, height / 2, 3, 3), blue);
|
c.drawRect(Rect.fromLTWH(width / 2, height / 2, 3, 3), blue);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,6 @@ class NineTileBoxComponent extends PositionComponent {
|
|||||||
@override
|
@override
|
||||||
void render(Canvas c) {
|
void render(Canvas c) {
|
||||||
super.render(c);
|
super.render(c);
|
||||||
nineTileBox.drawRect(c, toZeroRect());
|
nineTileBox.drawRect(c, toOriginRect());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,7 @@ abstract class PositionComponent extends Component {
|
|||||||
/// Returns the size of this component starting at (0, 0).
|
/// Returns the size of this component starting at (0, 0).
|
||||||
/// Effectively this is it's position with respect to itself.
|
/// Effectively this is it's position with respect to itself.
|
||||||
/// Use this if the canvas is already translated by (x, y).
|
/// Use this if the canvas is already translated by (x, y).
|
||||||
Rect toZeroRect() => Rect.fromLTWH(0, 0, width, height);
|
Rect toOriginRect() => Rect.fromLTWH(0, 0, width, height);
|
||||||
|
|
||||||
/// Returns the relative position/size of this component.
|
/// Returns the relative position/size of this component.
|
||||||
/// Relative because it might be translated by their parents (which is not considered here).
|
/// Relative because it might be translated by their parents (which is not considered here).
|
||||||
@ -116,7 +116,7 @@ abstract class PositionComponent extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void renderDebugMode(Canvas canvas) {
|
void renderDebugMode(Canvas canvas) {
|
||||||
canvas.drawRect(toZeroRect(), _debugPaint);
|
canvas.drawRect(toOriginRect(), _debugPaint);
|
||||||
debugTextConfig.render(
|
debugTextConfig.render(
|
||||||
canvas,
|
canvas,
|
||||||
'x: ${x.toStringAsFixed(2)} y:${y.toStringAsFixed(2)}',
|
'x: ${x.toStringAsFixed(2)} y:${y.toStringAsFixed(2)}',
|
||||||
@ -131,7 +131,7 @@ abstract class PositionComponent extends Component {
|
|||||||
Position(width - 50, height));
|
Position(width - 50, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepareCanvas(Canvas canvas) {
|
void _prepareCanvas(Canvas canvas) {
|
||||||
canvas.translate(x, y);
|
canvas.translate(x, y);
|
||||||
|
|
||||||
canvas.rotate(angle);
|
canvas.rotate(angle);
|
||||||
@ -201,7 +201,7 @@ abstract class PositionComponent extends Component {
|
|||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
@override
|
@override
|
||||||
void render(Canvas canvas) {
|
void render(Canvas canvas) {
|
||||||
prepareCanvas(canvas);
|
_prepareCanvas(canvas);
|
||||||
|
|
||||||
if (debugMode) {
|
if (debugMode) {
|
||||||
renderDebugMode(canvas);
|
renderDebugMode(canvas);
|
||||||
|
|||||||
@ -148,7 +148,7 @@ class TextBoxComponent extends PositionComponent with Resizable {
|
|||||||
|
|
||||||
Future<Image> _redrawCache() {
|
Future<Image> _redrawCache() {
|
||||||
final PictureRecorder recorder = PictureRecorder();
|
final PictureRecorder recorder = PictureRecorder();
|
||||||
final Canvas c = Canvas(recorder, toZeroRect());
|
final Canvas c = Canvas(recorder, toOriginRect());
|
||||||
_fullRender(c);
|
_fullRender(c);
|
||||||
return recorder.endRecording().toImage(width.toInt(), height.toInt());
|
return recorder.endRecording().toImage(width.toInt(), height.toInt());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user