# Bird.gd
extends RigidBody2D
func _physics_process(delta):
if Input.is_mouse_button_pressed(1): # 鼠标行为探测 active
linear_velocity = Vector2.UP * 500 # y轴线速度
angular_velocity = -4.0 # 角速度仰角
if rotation_degrees < -30: # 限制最大仰角
rotation_degrees = -30 # 仰角最大 -30°
angular_velocity = 0 # 仰角增速为 0
if linear_velocity.y > 0.0:
angular_velocity = 2.0
一直有个代码上的问题来球教, <限制最大仰角>
第八行代码实现了该功能, 但是超过的时候(如29+4>30)进行赋值 Input.is_mouse_button_pressed(1):
一直又在加仰角, 这俩会不会冲突哇? 并且或许计算机的资源消耗会很大?因为一直在处理这个冲突?
教程来源于 https://orzgame.blog.csdn.net/article/details/104606205