mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Deletes old test game Demo game is now playable Updates demo game with steering and changes in sprites Fixes smaller bugs in sprites Refactor class names in game demo Strips Box2D from game Fixes ordering in game node Adds frameRate property to SpriteBox and improves update methods. Fixes node to box transformations for hit tests Fixes minor code issues R=abarth@chromium.org Review URL: https://codereview.chromium.org/1179333002.
32 lines
807 B
Dart
32 lines
807 B
Dart
part of sprites;
|
|
|
|
abstract class NodeWithSize extends Node {
|
|
Size size;
|
|
Point pivot;
|
|
|
|
NodeWithSize() {
|
|
size = Size.zero;
|
|
pivot = Point.origin;
|
|
}
|
|
|
|
NodeWithSize.withSize(Size this.size, [Point this.pivot]);
|
|
|
|
void applyTransformForPivot(PictureRecorder canvas) {
|
|
if (pivot.x != 0 || pivot.y != 0) {
|
|
double pivotInPointsX = size.width * pivot.x;
|
|
double pivotInPointsY = size.height * pivot.y;
|
|
canvas.translate(-pivotInPointsX, -pivotInPointsY);
|
|
}
|
|
}
|
|
|
|
bool hitTest (Point nodePoint) {
|
|
|
|
double minX = -size.width * pivot.x;
|
|
double minY = -size.height * pivot.y;
|
|
double maxX = minX + size.width;
|
|
double maxY = minY + size.height;
|
|
return (nodePoint.x >= minX && nodePoint.x < maxX &&
|
|
nodePoint.y >= minY && nodePoint.y < maxY);
|
|
}
|
|
}
|