You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
721 B
GDScript
23 lines
721 B
GDScript
3 years ago
|
extends Node
|
||
|
class_name PlayerAttack
|
||
|
|
||
|
func run(actor, delta):
|
||
|
|
||
|
actor.getAnimatedSprite().animation = "slash"
|
||
|
actor.getAnimatedSprite().speed_scale = 4
|
||
|
var velocity = actor.last_process_velocity
|
||
|
velocity = velocity.normalized() * actor.speed
|
||
|
if velocity.length() > 0:
|
||
|
actor.getAnimatedSprite().play()
|
||
|
actor.position += velocity * delta * 0.5
|
||
|
actor.position.x = clamp(actor.position.x, 0, actor.get_viewport_rect().size.x)
|
||
|
actor.position.y = clamp(actor.position.y, 0, actor.get_viewport_rect().size.y)
|
||
|
actor.getAnimatedSprite().flip_h = velocity.x < 0
|
||
|
|
||
|
|
||
|
func spriteFinished(actor):
|
||
|
|
||
|
actor.state = actor.PlayerState.NORMAL
|
||
|
actor.getAnimatedSprite().flip_h = false
|
||
|
actor.getAnimatedSprite().speed_scale = 1
|