godot-shooter / commit
Adding a pop-up to show when exiting from a non-OSX device.
Player.gd | 7 ++++++- Popup.gd | 11 +++++++++++ Popup.tscn | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Player.gd b/Player.gd index f075ecf..3f2bcec 100644 --- a/Player.gd +++ b/Player.gd @@ -7,6 +7,7 @@ export var shot_period_seconds = .1 export var bullet: PackedScene #onready var bullet = preload("res://Bullet.tscn") +var PopupControl = preload("res://Popup.tscn") var dead = false var velocity = Vector2.ZERO @@ -15,7 +16,11 @@ var can_fire = true func _process(delta: float) -> void: if Input.is_action_just_pressed("exit"): - get_tree().quit() + var p = PopupControl.instance() + p.message = OS.get_name() + add_child(p) + if OS.get_name() == "OSX": + get_tree().quit() if Input.is_action_just_pressed("restart"): restart() if dead: diff --git a/Popup.gd b/Popup.gd new file mode 100644 index 0000000..e0d88de --- /dev/null +++ b/Popup.gd @@ -0,0 +1,11 @@ +extends Control + +export var message: String = "" + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + $PopupDialog/Label.text = message + $PopupDialog.popup() + +func _on_Button_pressed() -> void: + queue_free() diff --git a/Popup.tscn b/Popup.tscn new file mode 100644 index 0000000..7dea130 --- /dev/null +++ b/Popup.tscn @@ -0,0 +1,33 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Popup.gd" type="Script" id=1] + +[node name="Popup" type="Control"] +margin_right = 40.0 +margin_bottom = 40.0 +script = ExtResource( 1 ) + +[node name="PopupDialog" type="PopupDialog" parent="."] +visible = true +margin_right = 324.0 +margin_bottom = 179.0 + +[node name="Label" type="Label" parent="PopupDialog"] +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +margin_top = -7.0 +margin_bottom = 7.0 +text = "HI" + +[node name="Button" type="Button" parent="PopupDialog"] +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +margin_left = -23.5 +margin_top = -20.0 +margin_right = 23.5 +text = "Close" + +[connection signal="pressed" from="PopupDialog/Button" to="." method="_on_Button_pressed"]