Ejemplo n.º 1
0
    public void spawn_new_player()
    {
        Node2D main_scene = (Node2D)GetTree().Root.GetNode("Main");
        Timer  live_time  = new Timer();

        live_time.Connect("timeout", this, "remove_new_player");
        live_time.OneShot  = true;
        live_time.WaitTime = 10;
        live_time.Name     = "Grow_Live_Time";
        main_scene.AddChild(live_time);
        live_time.Start();
        KinematicBody2D player       = (KinematicBody2D)GetTree().Root.GetNode("Main").GetNode("Player");
        PackedScene     player_scene = GD.Load <PackedScene>("res://Scenes/Player.tscn");
        KinematicBody2D new_player   = (KinematicBody2D)player_scene.Instance();

        player.AddChild(new_player);
        new_player.Position = new Vector2(0, 0);
        GD.Print(live_time.TimeLeft);
    }