Fix viewport not moving when paused

main
copygirl 5 years ago
parent 4962f514e0
commit 9888c53d04
  1. 10
      scene/EscapeMenu.tscn
  2. 1
      scene/LocalPlayer.tscn
  3. 4
      src/Background.cs

@ -79,9 +79,9 @@ ColorSliderPath = NodePath("VBoxContainer/ContainerColor/Hue")
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Appearance"]
margin_left = 19.0
margin_top = 14.0
margin_top = 16.0
margin_right = 201.0
margin_bottom = 72.0
margin_bottom = 71.0
[node name="ContainerName" type="HBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Appearance/VBoxContainer"]
margin_right = 182.0
@ -136,12 +136,12 @@ scrollable = false
[node name="Label" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Appearance/VBoxContainer"]
margin_top = 42.0
margin_right = 182.0
margin_bottom = 57.0
rect_min_size = Vector2( 0, 15 )
margin_bottom = 54.0
rect_min_size = Vector2( 0, 12 )
custom_colors/font_color = Color( 0.6, 0.6, 0.6, 1 )
text = "(Close Menu to apply changes.)"
align = 1
valign = 1
valign = 2
[node name="Multiplayer" type="VBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer"]
visible = false

@ -7,4 +7,5 @@
script = ExtResource( 3 )
[node name="Camera" type="Camera2D" parent="." index="0"]
pause_mode = 2
current = true

@ -7,8 +7,8 @@ public class Background : TextureRect
var offset = new Vector2(8, 8);
var tileSize = Texture.GetSize();
var viewportSize = GetViewport().Size;
var camera = LocalPlayer.Instance.GetNode<Camera2D>("Camera");
RectPosition = ((camera.GlobalPosition - viewportSize / 2) / tileSize).Floor() * tileSize - offset;
var cameraPos = LocalPlayer.Instance.GetNode<Camera2D>("Camera").GetCameraPosition();
RectPosition = ((cameraPos - viewportSize / 2) / tileSize).Floor() * tileSize - offset;
RectSize = ((viewportSize + offset) / tileSize + Vector2.One).Ceil() * tileSize;
}
}

Loading…
Cancel
Save