chrismaltby / gb-studio

A quick and easy to use drag and drop retro game creator for your favourite handheld video game system
https://www.gbstudio.dev
MIT License
8.54k stars 471 forks source link

Cannot Replace Default Sprite for Scene Type #1134

Open dootmoon opened 2 years ago

dootmoon commented 2 years ago

Describe the bug (I think this might be a bug, but if it's just an operator error, I apologize.) I want the player to be able to chose between two different player characters with separate sprites at the beginning of the game. I use the "Set Player Sprite Sheet" event to do this, and I have "Replace Default For Scene Type" checked. The new sprite is set correctly, and I can switch between scenes keeping the same sprite. But if I save the game ("Game Data Save") and then load my save file ("Game Data Load"), the player sprite goes back to the original default. Is that supposed to happen?

Edit: After some further testing, I discovered that after loading the game, if I then go to a different scene, then the player switches to the correct sprite. So it looks like "Replace Default For Scene Type" is working, but it doesn't apply right after the game loads for some reason.

To Reproduce Steps to reproduce the behavior:

  1. Use the "Set Player Sprite Sheet" event to change the player's sprite.
  2. Save game.
  3. Load game.
  4. See error

Expected behavior I figured, especially with "Replace Default For Scene Type" checked, that the sprite sheet I set for the player would remain the same between saving and loading the game.

Platform (please complete the following information):

LordRembo commented 1 year ago

Did you ever figure out a solution? I have the same thing going on. What happens, is that Sprite changes on the Player are not saved as part of the the Save State. And since scenes are saved AFTER they have initialized, no scripts are executed, so your Sprite also isn't going to be set when a saved game loads. That explains why the Sprite does change when you switch scenes: it's because that scene re-initalizes and Sprite changes in response to the scripts on the Scene being executed.

LordRembo commented 1 year ago

In case anyone else is looking for a workaround, I've done this:

Now when a game is restored, the timer is still running and it will execute the sprite selection Script and then stop the timer

netcore10 commented 3 months ago

i get this too, this feature is integral for my game beyond saving and loading but the sprites don't persist