gabicho

Warper
Member
Joined
Feb 16, 2015
Messages
4
Reaction score
1
First Language
english
Primarily Uses
N/A
Hello
My game is an action game that uses an abs system.
I've tried to have the game change to enemy music when an enemy event is activated. After the enemies are killed, the game goes back to the saved BGM.
Pretty much the process is this:
Before entering a room with an enemy, I have the game save the current bgm and bgs.
1.png
Then the enemy's event activates the battle bgm
2.png
Once all the enemies are defeated, the game recalls the saved bgm and bgs and replays it.
3.png
This works fantastically and I've never had any issues. However, while playtesting today I realized that if you save in a room with enemies then restart the game completely, there will be no saved bgm to replay so you get this error:
4.png

My question is, is there a way to do a conditional branch to check if there is a saved BGM/BGS point to replay or else just play the map music over again? I don't want to just keep playing the BGM again from the start as I don't want to annoy players.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
600
First Language
Italian
Primarily Uses
RMVXA
There are many ways to achieve this:
  1. create a temporary object that is not stored in the save file and use that to determine whether or not the background music was saved;
  2. set a flag when loading a saved game and load a normal background music if the flag has been set to true, then set it to false;
  3. disallow saving the game in rooms with enemies;
  4. do not stop the background music in rooms with save points (similar to the previous one, which one is the best for you depends on how many rooms with enemies allow the player to save the game);
  5. call the normal method to play background music should the replay method throw an exception (this means using a rescue).
There are actually more ways to achieve this, you really have a lot of options here, there are no best options nor perfect ones, you just have to decide which one you are more comfortable with.
 

gabicho

Warper
Member
Joined
Feb 16, 2015
Messages
4
Reaction score
1
First Language
english
Primarily Uses
N/A
I can't believe I didn't think to disable save in enemy rooms geeze
As that's the fastest solution I'll be using that method! Thank you so much!
 

Latest Threads

Latest Posts

Latest Profile Posts

JRPG TextBox HTML - Part 2:
So I'm resuming work on the Shadowstar Trilogy. I've decided that it will take place between the end of G4 and the start of G5, and two of the Lost Rulers will be Twilight Sparkle and Sunset Shimmer (who is the moon princess in my AU).
Been working on some sprites, My favorite out of all of them is this guy, his name is Moss:
anyone else 'round here gonna be doing the retro game jam that's starting in a few days on itch.io?
I also wanted to say that my bro brought back nostalgia and got me a GBA SP for my birthday! Ah, the memories of Pokémon Sapphire and LeafGreen! It came in a gray shell but he ordered a red one so it'd look like the one I had as a kid. It looks brand new!
qhE9zC8.jpg
LsluASM.jpg

Forum statistics

Threads
108,940
Messages
1,040,766
Members
141,402
Latest member
OkamiKami
Top