Adding Custom Mid Song Events - kadedevteam/Kade-Engine-Offical GitHub Wiki
Adding Custom Mid-Song Events
First you need to determine at which point in the song you want the effect. For that compile with -debug in the command and press F2 when the game opens. When you open the song you want the effects in on the right it will appear beatShit and stepShit.
beatShit = curBeat and stepShit = curStep on the code. If you want more precession with the effect use the curStep but I'm going to use curBeat for this tutorial.
Now play the song until the part you want the event in and take note of which curStep/curBeat matches the time you want the event in and follow the rest of the guide below.
Go to PlayState.hx, CTRL+F super.beatHit(); and start writing the code below it. If you want only one event to happen on the song use and replace number with the curBeat you noted.
if (curBeat == number && curSong == 'name-of-the-song')
{
//code block
}
Example:
if (curBeat == 25 && curSong == 'Blammed')
{
boyfriend.playanim('hey', 'true');
}
If you want multiple events to happen in the same song use and replace number1 for the first curBeat you noted, replace the number2 with the second curBeat you noted and you can keep adding new cases if you need.
if (curSong == 'name-of-the-song')
{
switch (curBeat)
{
case number1:
// code block
case number2:
// code block
}
}
In the code block's you can play animations specific to that curBeat/curStep, change the sprites to new ones, you named it. Keep in mind if you want to play animations you might want to force them (Look at the Cheat Sheet below).
If you want the enemy to change sprite sheet you probably want to make two characters and when the curBeat/curStep event runs it changes the character. For example you start with pico but you want to change it to mom when the curBeat/curStep hits. Just add the code below to the event and replace the name of the character with mom. Boyfriend is a little bit different just change new Character to new Boyfriend
remove(dad);
dad = new Character(100, 100, 'name of character');
add(dad);
The same can be done with girlfriend and different FlxSprites like backgrounds. Just make sure you declared the variable outside an if/switch and/or a function like create(). Be creative!
(Example above: If the song is Blammed and the curBeat is 25, the dad(opponent) character changes to dad, and when the curBeat is 50 the player(boyfriend) changes to bf-christmas.)
Make sure that for the characters the assets are accessible. This means the assets for the characters they are changing into must be in shared or in the song's week folder. If they aren't it will break!