该函数'connect()'返回一个值,但从不使用此值。这是什么意思?



我是Godot的新手,正在创建我的第一个项目。有一件事让我很恼火;函数"connect(("返回一个值,但从未使用此值"我不知道该在代码行中添加什么,但我将首先显示代码:

extends KinematicBody2D
var gravity = 1000
var velocity = Vector2.ZERO
var maxHorizontalSpeed = 120
var horizontalAcceleration = 100
var jumpSpeed = 320
var jumpTerminationMultiplier = 4
var hasDoubleJump = false
func _ready():
warning-ignore:return_value_discarded
$HazardArea.connect("area_entered", self, "on_hazard_area_entered")
func _process(delta):
var moveVector = Vector2.ZERO
moveVector.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
moveVector.y = -1 if Input.is_action_just_pressed("jump") else 0
velocity.x += moveVector.x * horizontalAcceleration * delta
if (moveVector.x == 0):
velocity.x = lerp(0, velocity.x, pow(2, -50))

velocity.x = clamp(velocity.x,  -maxHorizontalSpeed, maxHorizontalSpeed)

if (moveVector.y < 0 && (is_on_floor() || $CoyoteTimer.is_stopped() || hasDoubleJump)):
velocity.y = moveVector.y * jumpSpeed
if(!is_on_floor() && $CoyoteTimer.is_stopped()):
hasDoubleJump = false
$CoyoteTimer.stop()
if(moveVector.y < 0 && !Input.is_action_just_pressed("jump")):
velocity.x = gravity * jumpTerminationMultiplier * delta
else:
velocity.y += gravity * delta
var wasOnFloor = is_on_floor()
velocity = move_and_slide(velocity, Vector2.UP)
if(wasOnFloor && !is_on_floor()):
$CoyoteTimer.start()
if(is_on_floor()):
hasDoubleJump = true
update_animation()
func get_movement_vector():
var moveVector = Vector2.ZERO
moveVector.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
moveVector.y = -1 if Input.is_action_just_pressed("jump") else 0
return moveVector
func update_animation():
var moveVec = get_movement_vector()
if(!is_on_floor()):
$AnimatedSprite.play("Jump")
elif(moveVec.x != 0):
$AnimatedSprite.play("Run")      
else:
$AnimatedSprite.play("Idle")
$AnimatedSprite.flip_h = true if moveVec.x > 0 else false

func on_hazard_area_entered(_area2d):
print("die")

问题在13号线上,我真的很感激你的帮助!

这个问题没有解决方案。你唯一能做的就是:

  1. 或者使用返回值(如果需要(
  2. 或按警告选项卡中的忽略

此链接可以为您提供更多帮助https://godotengine.org/qa/78337/the-function-connect-returns-value-but-this-value-never-used

相关内容

最新更新