mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 20:13:50 +08:00
box2d and parallax
This commit is contained in:
@ -111,17 +111,17 @@ class Viewport extends ViewportTransform {
|
||||
: super(new Vector2(dimensions.width / 2, dimensions.height / 2),
|
||||
new Vector2(dimensions.width / 2, dimensions.height / 2), scale);
|
||||
|
||||
double alignBottom(double height) =>
|
||||
double worldAlignBottom(double height) =>
|
||||
-(dimensions.height / 2 / scale) + height;
|
||||
|
||||
/**
|
||||
* Computes the number of horizontal pixels of this viewport considering a
|
||||
* Computes the number of horizontal world meters of this viewport considering a
|
||||
* percentage of its width.
|
||||
*
|
||||
* @param percent percetage of the width in [0, 1] range
|
||||
*/
|
||||
double width(double percent) {
|
||||
return percent * (dimensions.width / 2 / scale);
|
||||
double worldWidth(double percent) {
|
||||
return percent * (dimensions.width / scale);
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +202,8 @@ abstract class BodyComponent extends Component {
|
||||
}
|
||||
|
||||
void drawPolygon(Canvas canvas, List<Offset> points) {
|
||||
final path = new Path()..addPolygon(points, true);
|
||||
final path = new Path()
|
||||
..addPolygon(points, true);
|
||||
final Paint paint = new Paint()
|
||||
..color = new Color.fromARGB(255, 255, 255, 255);
|
||||
// ..style = PaintingStyle.stroke;
|
||||
|
||||
@ -100,8 +100,10 @@ class ParallaxComponent extends PositionComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
prepareCanvas(canvas);
|
||||
_drawLayers(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
void _drawLayers(Canvas canvas) {
|
||||
|
||||
Reference in New Issue
Block a user