mirror of
https://github.com/Relintai/broken_seals_roguelike.git
synced 2024-11-14 10:57:19 +01:00
Fix InputEvent coordinate space conversion.
This commit is contained in:
parent
c0388997c1
commit
0b0fceb2b9
@ -140,9 +140,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
camera.zoom -= Vector2(event.factor, event.factor) * 0.01
|
camera.zoom -= Vector2(event.factor, event.factor) * 0.01
|
||||||
elif event.button_index == BUTTON_LEFT and event.device != -1:
|
elif event.button_index == BUTTON_LEFT and event.device != -1:
|
||||||
if event.pressed:
|
if event.pressed:
|
||||||
#https://github.com/godotengine/godot/issues/32222
|
var pos : Vector2 = world.make_canvas_position_local(event.position)
|
||||||
var pos = event.position - get_viewport_transform().origin
|
|
||||||
pos *= camera.zoom
|
|
||||||
|
|
||||||
pos -= transform.origin
|
pos -= transform.origin
|
||||||
|
|
||||||
@ -180,9 +178,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
|
|
||||||
if event is InputEventScreenTouch and event.pressed:
|
if event is InputEventScreenTouch and event.pressed:
|
||||||
if !target(event.position):
|
if !target(event.position):
|
||||||
#https://github.com/godotengine/godot/issues/32222
|
var pos : Vector2 = world.make_canvas_position_local(event.position)
|
||||||
var pos = event.position - get_viewport_transform().origin
|
|
||||||
pos *= camera.zoom
|
|
||||||
|
|
||||||
pos -= transform.origin
|
pos -= transform.origin
|
||||||
|
|
||||||
@ -271,9 +267,7 @@ func set_tile_position(pos : Vector2) -> void:
|
|||||||
transform.origin = pos * tile_size + Vector2(tile_size / 2, tile_size / 2)
|
transform.origin = pos * tile_size + Vector2(tile_size / 2, tile_size / 2)
|
||||||
|
|
||||||
func target(position : Vector2) -> bool:
|
func target(position : Vector2) -> bool:
|
||||||
#https://github.com/godotengine/godot/issues/32222
|
position = world.make_canvas_position_local(position)
|
||||||
position = position - get_viewport_transform().origin
|
|
||||||
position *= camera.zoom
|
|
||||||
|
|
||||||
var pos : Vector2 = world.pixel_to_tile(position.x, position.y)
|
var pos : Vector2 = world.pixel_to_tile(position.x, position.y)
|
||||||
var enemy : Entity = world.get_enemy_at_tile(pos.x, pos.y)
|
var enemy : Entity = world.get_enemy_at_tile(pos.x, pos.y)
|
||||||
|
Loading…
Reference in New Issue
Block a user