Skip to content

Commit

Permalink
Fixed bug where clicking outside map would result in crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
ra314 committed Aug 12, 2021
1 parent 58b8c05 commit 67f40ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Scripts/Level_Funcs.gd
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ func get_color_in_mask():

func _input(event):
if event.is_pressed():
if not (Rect2(Vector2(0,0), world_mask.get_size()).has_point(get_local_mouse_position())):
return

# Print color of pixel under mouse cursos when clicked
print(world_mask.get_pixel(get_local_mouse_position()[0]*2, get_local_mouse_position()[1]*2)*255)
print(get_color_in_mask())

var country_name = get_color_in_mask()[0]
if country_name in all_countries:
Expand Down

0 comments on commit 67f40ce

Please sign in to comment.