fix: frame edge camera states inside play area
This commit is contained in:
+13
-4
@@ -343,6 +343,7 @@ func _prepare_exit_capture_state() -> void:
|
||||
_sync_map_renderer_visibility()
|
||||
_sync_minimap()
|
||||
player_view.refresh()
|
||||
_configure_camera()
|
||||
_sync_camera_to_player()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
@@ -1994,10 +1995,18 @@ func _create_initial_state() -> GameState:
|
||||
|
||||
func _configure_camera() -> void:
|
||||
var map_size := game_state.map.size * TILE_SIZE
|
||||
camera.limit_left = $World.position.x
|
||||
camera.limit_top = $World.position.y
|
||||
camera.limit_right = $World.position.x + map_size.x
|
||||
camera.limit_bottom = $World.position.y + map_size.y
|
||||
# Camera2D clamps against its full engine viewport, while opaque HUD masks
|
||||
# expose only PlayAreaFrame. Extend each map edge by the difference between
|
||||
# those half-extents so actors at a map edge remain inside the framed area
|
||||
# instead of being pinned against its border.
|
||||
var frame := hud.get_node_or_null("ResponsiveLayout/PlayAreaFrame") as Control
|
||||
var viewport_half := get_viewport().get_visible_rect().size / camera.zoom * 0.5
|
||||
var frame_half := frame.get_global_rect().size / camera.zoom * 0.5 if frame != null else viewport_half
|
||||
var limit_padding := viewport_half - frame_half
|
||||
camera.limit_left = floori($World.position.x - limit_padding.x)
|
||||
camera.limit_top = floori($World.position.y - limit_padding.y)
|
||||
camera.limit_right = ceili($World.position.x + map_size.x + limit_padding.x)
|
||||
camera.limit_bottom = ceili($World.position.y + map_size.y + limit_padding.y)
|
||||
_sync_camera_to_player()
|
||||
|
||||
func _sync_camera_to_player() -> void:
|
||||
|
||||
Reference in New Issue
Block a user