gamepad disconnect warning
This commit is contained in:
parent
6440bf4737
commit
832561a573
2 changed files with 23 additions and 4 deletions
|
@ -9,11 +9,14 @@ var musictrack
|
||||||
var bhud = load("res://levels/bottomhud.tscn").instance()
|
var bhud = load("res://levels/bottomhud.tscn").instance()
|
||||||
var thud = load("res://levels/ui/tophud.tscn").instance()
|
var thud = load("res://levels/ui/tophud.tscn").instance()
|
||||||
var pmenu = load("res://levels/ui/pause.tscn").instance()
|
var pmenu = load("res://levels/ui/pause.tscn").instance()
|
||||||
|
var mgamepad = load("res://levels/ui/missinggamepad.tscn").instance()
|
||||||
|
var ismgamepad = false
|
||||||
var ispaused = false
|
var ispaused = false
|
||||||
var ishud = true
|
var ishud = true
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
Input.connect("joy_connection_changed",self,"_on_joy_connection_changed")
|
||||||
_statrebase()
|
_statrebase()
|
||||||
add_child(bgsound)
|
add_child(bgsound)
|
||||||
add_child(sfx1)
|
add_child(sfx1)
|
||||||
|
@ -60,6 +63,11 @@ func _process(delta):
|
||||||
#velocity = (Vector2.RIGHT.rotated(rotation) * -100 * Global.xm * delta)-Vector2.UP.rotated(rotation) * -100 * Global.ym * delta
|
#velocity = (Vector2.RIGHT.rotated(rotation) * -100 * Global.xm * delta)-Vector2.UP.rotated(rotation) * -100 * Global.ym * delta
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
|
if ismgamepad && (event is InputEventJoypadButton || Input.is_key_pressed(KEY_ENTER)):
|
||||||
|
ismgamepad = false
|
||||||
|
get_tree().root.remove_child(mgamepad)
|
||||||
|
Global.live = 1
|
||||||
|
|
||||||
gamepadtest.new(event)
|
gamepadtest.new(event)
|
||||||
if Input.is_action_just_pressed("Pause") && Global.cdialog == []:
|
if Input.is_action_just_pressed("Pause") && Global.cdialog == []:
|
||||||
_pausemenu()
|
_pausemenu()
|
||||||
|
@ -163,6 +171,12 @@ func _exit():
|
||||||
Global.live = 0
|
Global.live = 0
|
||||||
get_tree().change_scene("res://title.tscn")
|
get_tree().change_scene("res://title.tscn")
|
||||||
|
|
||||||
|
func _on_joy_connection_changed(device_id, connected):
|
||||||
|
if !ismgamepad && !connected && Global.gamepad != 0 && Global.live == 1:
|
||||||
|
ismgamepad = true
|
||||||
|
Global.live = 4
|
||||||
|
call_deferred("_mgamepad")
|
||||||
|
|
||||||
func _level():
|
func _level():
|
||||||
get_tree().root.add_child(level)
|
get_tree().root.add_child(level)
|
||||||
|
|
||||||
|
@ -174,3 +188,6 @@ func _bhud():
|
||||||
|
|
||||||
func _pmenu():
|
func _pmenu():
|
||||||
get_tree().root.add_child(pmenu)
|
get_tree().root.add_child(pmenu)
|
||||||
|
|
||||||
|
func _mgamepad():
|
||||||
|
get_tree().root.add_child(mgamepad)
|
||||||
|
|
|
@ -4,17 +4,19 @@
|
||||||
|
|
||||||
[node name="Missinggamepad" type="Node2D"]
|
[node name="Missinggamepad" type="Node2D"]
|
||||||
|
|
||||||
[node name="ColorRect" type="ColorRect" parent="."]
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="CanvasLayer"]
|
||||||
margin_left = 90.0
|
margin_left = 90.0
|
||||||
margin_top = 211.0
|
margin_top = 211.0
|
||||||
margin_right = 1177.0
|
margin_right = 1197.0
|
||||||
margin_bottom = 511.0
|
margin_bottom = 511.0
|
||||||
color = Color( 0, 0, 0, 1 )
|
color = Color( 0, 0, 0, 1 )
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="CanvasLayer"]
|
||||||
margin_left = 90.0
|
margin_left = 90.0
|
||||||
margin_top = 211.0
|
margin_top = 211.0
|
||||||
margin_right = 1177.0
|
margin_right = 1197.0
|
||||||
margin_bottom = 511.0
|
margin_bottom = 511.0
|
||||||
rect_min_size = Vector2( 1072, 300 )
|
rect_min_size = Vector2( 1072, 300 )
|
||||||
custom_fonts/font = ExtResource( 1 )
|
custom_fonts/font = ExtResource( 1 )
|
||||||
|
|
Loading…
Reference in a new issue