mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 20:36:31 +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),
|
: super(new Vector2(dimensions.width / 2, dimensions.height / 2),
|
||||||
new Vector2(dimensions.width / 2, dimensions.height / 2), scale);
|
new Vector2(dimensions.width / 2, dimensions.height / 2), scale);
|
||||||
|
|
||||||
double alignBottom(double height) =>
|
double worldAlignBottom(double height) =>
|
||||||
-(dimensions.height / 2 / scale) + 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.
|
* percentage of its width.
|
||||||
*
|
*
|
||||||
* @param percent percetage of the width in [0, 1] range
|
* @param percent percetage of the width in [0, 1] range
|
||||||
*/
|
*/
|
||||||
double width(double percent) {
|
double worldWidth(double percent) {
|
||||||
return percent * (dimensions.width / 2 / scale);
|
return percent * (dimensions.width / scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +202,8 @@ abstract class BodyComponent extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void drawPolygon(Canvas canvas, List<Offset> points) {
|
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()
|
final Paint paint = new Paint()
|
||||||
..color = new Color.fromARGB(255, 255, 255, 255);
|
..color = new Color.fromARGB(255, 255, 255, 255);
|
||||||
// ..style = PaintingStyle.stroke;
|
// ..style = PaintingStyle.stroke;
|
||||||
|
|||||||
@ -100,8 +100,10 @@ class ParallaxComponent extends PositionComponent {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canvas.save();
|
||||||
prepareCanvas(canvas);
|
prepareCanvas(canvas);
|
||||||
_drawLayers(canvas);
|
_drawLayers(canvas);
|
||||||
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _drawLayers(Canvas canvas) {
|
void _drawLayers(Canvas canvas) {
|
||||||
|
|||||||
Reference in New Issue
Block a user