mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
更新EntityBase和Rooster类,添加动画支持并修复变量命名
This commit is contained in:
@@ -4,12 +4,19 @@ class_name EntityBase # 这是个抽象类
|
||||
@export var maxHealth: float = 100
|
||||
@export var movementSpeed: float = 100
|
||||
|
||||
@onready var animatree = $"%animatree"
|
||||
@onready var texture = $"%texture"
|
||||
@onready var hurtbox = $"%hurtbox"
|
||||
|
||||
var health: float = 0
|
||||
|
||||
var lastDirection: int = 1
|
||||
|
||||
func _ready():
|
||||
health = maxHealth
|
||||
func _process(_delta):
|
||||
health = clamp(health, 0, maxHealth)
|
||||
animatree.set("parameters/blend_position", lerpf(animatree.get("parameters/blend_position"), lastDirection, 0.1))
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
ai()
|
||||
@@ -18,6 +25,9 @@ func _physics_process(_delta: float) -> void:
|
||||
# 通用方法
|
||||
func move(direction: Vector2):
|
||||
velocity = direction.normalized() * movementSpeed
|
||||
var currentDirection = sign(direction.x)
|
||||
if currentDirection != 0:
|
||||
lastDirection = currentDirection
|
||||
|
||||
# 抽象方法
|
||||
func ai():
|
||||
|
||||
Reference in New Issue
Block a user