box2d and parallax

This commit is contained in:
feroult
2017-11-23 10:35:39 -02:00
parent 82af4ef286
commit d1b547ee1a
2 changed files with 16 additions and 13 deletions

View File

@ -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;

View File

@ -100,8 +100,10 @@ class ParallaxComponent extends PositionComponent {
return;
}
canvas.save();
prepareCanvas(canvas);
_drawLayers(canvas);
canvas.restore();
}
void _drawLayers(Canvas canvas) {