allow switching sides of ladder (implements #212)
This commit is contained in:
parent
cb6a9e13f4
commit
8299648c98
3 changed files with 23 additions and 1 deletions
|
@ -1,5 +1,8 @@
|
||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
|
export var can_climb_left: bool = true
|
||||||
|
export var can_climb_right: bool = true
|
||||||
|
|
||||||
onready var left_snap: float = $LeftSnap.global_position.x
|
onready var left_snap: float = $LeftSnap.global_position.x
|
||||||
onready var right_snap: float = $RightSnap.global_position.x
|
onready var right_snap: float = $RightSnap.global_position.x
|
||||||
onready var middle: float = global_position.x + 4.0
|
onready var middle: float = global_position.x + 4.0
|
||||||
|
|
|
@ -267,10 +267,11 @@ func _on_Climbing_state_entered() -> void:
|
||||||
if ladder_dir >= 0.0 != flip:
|
if ladder_dir >= 0.0 != flip:
|
||||||
global_position.x = _attached_ladder.left_snap
|
global_position.x = _attached_ladder.left_snap
|
||||||
graphics.scale.x = 1.0
|
graphics.scale.x = 1.0
|
||||||
|
animation_player.play("climb")
|
||||||
else:
|
else:
|
||||||
global_position.x = _attached_ladder.right_snap
|
global_position.x = _attached_ladder.right_snap
|
||||||
graphics.scale.x = -1.0
|
graphics.scale.x = -1.0
|
||||||
animation_player.play("climb")
|
animation_player.play("climb")
|
||||||
|
|
||||||
func _on_Climbing_state_exited() -> void:
|
func _on_Climbing_state_exited() -> void:
|
||||||
_attached_ladder = null
|
_attached_ladder = null
|
||||||
|
@ -453,6 +454,12 @@ func _process_climbing(delta: float) -> void:
|
||||||
# if sign(_attached_ladder.middle - global_position.x) != horizontal_dir:
|
# if sign(_attached_ladder.middle - global_position.x) != horizontal_dir:
|
||||||
# global_position.x -= graphics.scale.x * 3.0
|
# global_position.x -= graphics.scale.x * 3.0
|
||||||
# state_chart.send_event("ladder_detach")#
|
# state_chart.send_event("ladder_detach")#
|
||||||
|
elif Input.is_action_just_pressed("move_left") and _attached_ladder.can_climb_left:
|
||||||
|
global_position.x = _attached_ladder.left_snap
|
||||||
|
graphics.scale.x = 1.0
|
||||||
|
elif Input.is_action_just_pressed("move_right") and _attached_ladder.can_climb_right:
|
||||||
|
global_position.x = _attached_ladder.right_snap
|
||||||
|
graphics.scale.x = -1.0
|
||||||
else:
|
else:
|
||||||
var ladder_dir = sign(_attached_ladder.middle - global_position.x)
|
var ladder_dir = sign(_attached_ladder.middle - global_position.x)
|
||||||
if ladder_dir >= 0.0:
|
if ladder_dir >= 0.0:
|
||||||
|
|
|
@ -815,6 +815,18 @@ tracks/2/keys = {
|
||||||
"update": 1,
|
"update": 1,
|
||||||
"values": [ 0, 1, 2, 3, 4, 5, 6, 7 ]
|
"values": [ 0, 1, 2, 3, 4, 5, 6, 7 ]
|
||||||
}
|
}
|
||||||
|
tracks/3/type = "value"
|
||||||
|
tracks/3/path = NodePath("Graphics/Sprite:rotation_degrees")
|
||||||
|
tracks/3/interp = 1
|
||||||
|
tracks/3/loop_wrap = true
|
||||||
|
tracks/3/imported = false
|
||||||
|
tracks/3/enabled = true
|
||||||
|
tracks/3/keys = {
|
||||||
|
"times": PoolRealArray( 0 ),
|
||||||
|
"transitions": PoolRealArray( 1 ),
|
||||||
|
"update": 0,
|
||||||
|
"values": [ 0.0 ]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id=11]
|
[sub_resource type="Animation" id=11]
|
||||||
resource_name = "shoot_airborne"
|
resource_name = "shoot_airborne"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue