Stomp fix

This commit is contained in:
Sagi Dayan 2020-11-26 23:27:58 -05:00
parent 03596b833e
commit 740d3c9dba
2 changed files with 15 additions and 11 deletions

View file

@ -140,7 +140,6 @@ position = Vector2( 104, 40 )
to_point = Vector2( 94, 0 )
duration = 0.8
delay = 0.2
g = "UP_DOWN"
[node name="SpikeTrap" parent="Hazards" instance=ExtResource( 18 )]
position = Vector2( 383, 48 )

View file

@ -7,18 +7,23 @@ export var duration := 2.0 setget set_duration
export var delay := .5 setget set_delay
export(String, "UP_DOWN", "LEFT_RIGHT") var g = "UP_DOWN"
onready var tween = $Tween
onready var sprite = $Sprite
var sprite:Sprite
var tween:Tween
var _is_ready = false
func _ready() -> void:
_is_ready = true;
_is_ready = true
sprite = $Sprite
tween = $Tween
tween.repeat = true
start_motion()
func _enter_tree() -> void:
if _is_ready: tween.resume_all()
func _on_DeathZone_body_entered(body:Node) -> void:
if body.name == "Player":
body.die()
body.die()
func set_to_position(val):
print("set_to_position")
@ -35,14 +40,14 @@ func set_delay(val):
print("set_delay")
delay = val
start_motion()
func start_motion():
if not _is_ready: return
print("Stomp Start Motion")
sprite.position = Vector2.ZERO
tween.stop_all()
tween.repeat = true
tween.interpolate_property(sprite, "position", Vector2.ZERO, to_point, duration, Tween.TRANS_LINEAR, Tween.EASE_IN, delay)
tween.interpolate_property(sprite, "position", to_point, Vector2.ZERO, duration, Tween.TRANS_LINEAR, Tween.EASE_IN, duration+(delay*2))
tween.start()
tween.remove_all()
print(tween.interpolate_property(sprite, "position", Vector2.ZERO, to_point, duration, Tween.TRANS_LINEAR, Tween.EASE_IN, delay))
print(tween.interpolate_property(sprite, "position", to_point, Vector2.ZERO, duration, Tween.TRANS_LINEAR, Tween.EASE_IN, duration+(delay*2)))
print(tween.start())