예제 #1
0
    public override void _Process(float time)
    {
        GD.Print("process");
        animationPlayer = (AnimationPlayer)GetNode("LoadScreenAnim");
        progressBar     = (ProgressBar)GetNode("ProgressBar");
        //
        if (loader == null)
        {
            //no need to process anymore
            SetProcess(false);
            return;
        }
        //Wait for frames to let the "loading" animation show up.
        if (wait_frames > 0)
        {
            wait_frames -= 1;
            return;
        }
        update_progress();
        var t = OS.GetTicksMsec();

        // Use "time_max" to control for how long we block this thread.
        while (OS.GetTicksMsec() < t + time_max)
        {
            // Poll your loader.
            var err = loader.Poll();
            if (err.ToString() == "FileEof") // Finished loading.
            {
                PackedScene resource = loader.GetResource() as PackedScene;
                loader.Dispose();
                Visible = false;
                set_new_scene(resource);
                break;
            }
            else if (err.ToString() == "Ok")
            {
                //update_progress();
            }
            else  // Error during loading.
                  //show_error();
            {
                loader = null;
                break;
            }
        }
    }
예제 #2
0
    public void goto_scene(string path)   // Game requests to switch to this scene.
    {
        SetProcess(true);
        //
        animationPlayer = (AnimationPlayer)GetNode("LoadScreenAnim");
        progressBar     = (ProgressBar)GetNode("ProgressBar");
        //
        animationPlayer.Play("show");
        //
        Node root = GetTree().Root;

        //current_scene = root.GetChild(root.GetChildCount() -1);
        foreach (Node child in root.GetChildren())
        {
            if (!(child is Global) && !(child is GenerateArcade))
            {
                child.QueueFree();
            }
        }
        loader      = ResourceLoader.LoadInteractive(path);
        is_charging = true;
        if (loader == null) // Check for errors.
        //show_error();
        {
            return;
            //SetProcess(true);
        }


        //current_scene.QueueFree(); // Get rid of the old scene.

        // Start your "loading..." animation.
        animationPlayer.Play("loading");
        //
        update_tips();
        //
        wait_frames = 1;
        //
    }