Fixed #19 so that the backgrounds stay in position when resized on a game over.
This commit is contained in:
parent
c5f22f7f21
commit
90c8a0566c
@ -377,17 +377,18 @@ class CircuitBackground extends MovingObject {
|
||||
|
||||
@override
|
||||
void resize(Vector2 newSize, double xRatio, double yRatio) {
|
||||
background1Size =
|
||||
Vector2(newSize.y * (background.width / background.height), newSize.y);
|
||||
background1Position.x *= xRatio;
|
||||
background1Position.y *= yRatio;
|
||||
background1Size.x *= xRatio;
|
||||
background1Size.y *= yRatio;
|
||||
background2Position.x *= xRatio;
|
||||
background2Position.y *= yRatio;
|
||||
background2Size.x *= xRatio;
|
||||
background2Size.y *= yRatio;
|
||||
windowA.position = background1Position;
|
||||
windowA.size = background1Size;
|
||||
overlayA.position = background1Position;
|
||||
overlayA.size = background1Size;
|
||||
|
||||
background2Position =
|
||||
Vector2(background1Position.x + background1Size.x - 1, 0);
|
||||
background2Size =
|
||||
Vector2(newSize.y * (background.width / background.height), newSize.y);
|
||||
windowB.position = background2Position;
|
||||
windowB.size = background2Size;
|
||||
overlayB.position = background2Position;
|
||||
|
@ -458,14 +458,14 @@ class Runner extends Component with HasGameRef<MyGame> {
|
||||
}
|
||||
}
|
||||
|
||||
for (List<MovingObject> debrisLevel in gameRef.wallHolder.objects) {
|
||||
for (int i = 0; i < debrisLevel.length; i++) {
|
||||
for (List<MovingObject> wallLevel in gameRef.wallHolder.objects) {
|
||||
for (int i = 0; i < wallLevel.length; i++) {
|
||||
Rect slim = Rect.fromLTRB(
|
||||
runnerRect.left + sprite.width / 3,
|
||||
runnerRect.top + sprite.height / (runnerState == "duck" ? 3 : 6),
|
||||
runnerRect.right - sprite.width / 3,
|
||||
runnerRect.bottom - sprite.height / 3);
|
||||
String intersectState = debrisLevel[i].intersect(slim);
|
||||
String intersectState = wallLevel[i].intersect(slim);
|
||||
if (intersectState == "none") {
|
||||
continue;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user