Ejemplo n.º 1
0
 public void Move(Godot.Sprite someChild)
 {
     if (Input.IsKeyPressed((int)KeyList.W))
     {
         this.Position           += new Vector2(0, -speed);
         someChild.GlobalPosition = new Vector2(0, 0);
     }
     if (Input.IsKeyPressed((int)KeyList.S))
     {
         this.Position += new Vector2(0, speed);
     }
     if (Input.IsKeyPressed((int)KeyList.A))
     {
         this.Position += new Vector2(-speed, 0);
     }
     if (Input.IsKeyPressed((int)KeyList.D))
     {
         this.Position += new Vector2(speed, 0);
     }
 }
Ejemplo n.º 2
0
    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(float delta)
    {
        Godot.Sprite child  = this.GetNode <Godot.Sprite>("Child");
        float        AMOUNT = 5;

        if (Input.IsKeyPressed((int)KeyList.W))
        {
            this.Position       += new Vector2(0, -AMOUNT);
            child.GlobalPosition = new Vector2(0, 0);
        }
        if (Input.IsKeyPressed((int)KeyList.S))
        {
            this.Position += new Vector2(0, AMOUNT);
        }
        if (Input.IsKeyPressed((int)KeyList.A))
        {
            this.Position += new Vector2(-AMOUNT, 0);
        }
        if (Input.IsKeyPressed((int)KeyList.D))
        {
            this.Position += new Vector2(AMOUNT, 0);
        }
    }
Ejemplo n.º 3
0
 // Called every frame. 'delta' is the elapsed time since the previous frame.
 public override void _Process(float delta)
 {
     Godot.Sprite child = this.GetNode <Godot.Sprite>("Sprite2");
     Move(child);
 }