feat: try instantiating dragon at correct size
This commit is contained in:
parent
eb081515c0
commit
a169e953c3
3 changed files with 10 additions and 5 deletions
|
@ -42,7 +42,6 @@ func _instantiate_dragon_ingame(position: Vector2):
|
|||
|
||||
|
||||
func _pick_dragon(position: Vector2):
|
||||
print(position)
|
||||
var dragon: Dragon = _instantiator.instantiate(position)
|
||||
dragon.place_back.connect(_dragon_place_back)
|
||||
add_child(dragon)
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
[node name="DragonPopup" type="Window"]
|
||||
disable_3d = true
|
||||
transparent_bg = true
|
||||
position = Vector2i(0, 36)
|
||||
size = Vector2i(128, 128)
|
||||
unresizable = true
|
||||
borderless = true
|
||||
|
|
|
@ -15,12 +15,15 @@ func instantiate(position: Vector2) -> Node:
|
|||
return _instantiate_dragon(relative_position)
|
||||
|
||||
|
||||
func _calculate_relative_position(position: Vector2) -> Vector2i:
|
||||
func _calculate_window_scale() -> Vector2:
|
||||
var viewport_size: Vector2 = _viewport.get_texture().get_size()
|
||||
var window_size: Vector2 = _window.get_size_with_decorations()
|
||||
|
||||
var scale: Vector2 = window_size / viewport_size
|
||||
|
||||
return window_size / viewport_size
|
||||
|
||||
|
||||
func _calculate_relative_position(position: Vector2) -> Vector2i:
|
||||
var scale: Vector2 = _calculate_window_scale()
|
||||
return Vector2i(Vector2(position) * scale)
|
||||
|
||||
|
||||
|
@ -31,6 +34,10 @@ func _instantiate_dragon(relative_position: Vector2i) -> Node:
|
|||
var window_size: Vector2i = DisplayServer.window_get_size()
|
||||
|
||||
dragon.position = window_position + relative_position - dragon.size / 2
|
||||
|
||||
var size: float = _calculate_window_scale().y
|
||||
dragon.size = Vector2i(dragon.size.x * size, dragon.size.y * size)
|
||||
dragon.content_scale_factor = 0.5
|
||||
dragon.main_window_rect = Rect2i(window_position, window_size)
|
||||
dragon.show()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue