add 注释
This commit is contained in:
parent
29decd4384
commit
6622e33f35
|
@ -0,0 +1 @@
|
|||
2ddemo
|
|
@ -22,30 +22,38 @@ public partial class Player : Area2D
|
|||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
// Player坐标, 初始化0,0
|
||||
var velocity = Vector2.Zero; // The player's movement vector.
|
||||
|
||||
// 如果按下右键 X轴+1
|
||||
if (Input.IsActionPressed("move_right"))
|
||||
{
|
||||
velocity.X += 1;
|
||||
}
|
||||
|
||||
// 左键 X轴-1
|
||||
if (Input.IsActionPressed("move_left"))
|
||||
{
|
||||
velocity.X -= 1;
|
||||
}
|
||||
|
||||
// 下键 Y轴+1
|
||||
if (Input.IsActionPressed("move_down"))
|
||||
{
|
||||
velocity.Y += 1;
|
||||
}
|
||||
|
||||
// 上键 Y轴-1
|
||||
if (Input.IsActionPressed("move_up"))
|
||||
{
|
||||
velocity.Y -= 1;
|
||||
}
|
||||
|
||||
|
||||
// 动画 获取AnimatedSprite2D节点
|
||||
var animatedSprite2D = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
|
||||
|
||||
// 如果坐标的length大于0
|
||||
if (velocity.Length() > 0)
|
||||
{
|
||||
velocity = velocity.Normalized() * Speed;
|
||||
|
|
Loading…
Reference in New Issue