Slide.gd 645 B

12345678910111213141516171819202122232425262728
  1. @icon("res://common/graphics/icons/godot_icon_slide.svg")
  2. class_name Slide
  3. extends Node2D
  4. # Display slide content
  5. signal finished
  6. var center_offset: Vector2
  7. func _ready():
  8. center_offset = _compute_center_offset()
  9. func get_center():
  10. return get_position() + center_offset
  11. func _unhandled_key_input(event: InputEvent):
  12. if event.is_action("ui_accept") and event.is_pressed():
  13. finished.emit()
  14. func _compute_center_offset() -> Vector2:
  15. var w: float = ProjectSettings.get("display/window/size/viewport_width")
  16. var h: float = ProjectSettings.get("display/window/size/viewport_height")
  17. return Vector2(w * scale.x / 2, h * scale.y / 2)