0

I implemented a sqlite db that saves a 'scene' name, which is the name of the class the scene takes place in.

So I have a 'MainPage', 'Scene2', 'Scene3' that are all classes with their own stack layouts.

I have checked that, upon a button click, it is returning the sceneID. I just have no idea how I would then load the class that shares the sceneID as its name to the screen so that the player would see that class's stack layout.

        private void loadButton_Clicked(object sender, EventArgs e)
        {
            SceneState state = LoadScene();
            Console.WriteLine($"SceneId: {state.SceneId}"); // these writelines were to verify the data returned
            Console.WriteLine($"ButtonText: {state.ButtonText}");
            Console.WriteLine($"Hp: {state.Hp}");
            Console.WriteLine($"Style: {state.Style}");
        }

        private SceneState LoadScene()
        {
            lock (_context)
            {
                return _context.Database.Table<SceneState>().FirstOrDefault();
            }
        }

Thank you.

  • Many ways to do this. It could be a map you manage yourself and naming convention you come up with or something else. This could also be based on Shell navigation with Forms or MAUI where you register routes that match your scene names. – Cheesebaron Feb 10 '23 at 13:08

0 Answers0