I have a little prototype right now where I have a main menu and two crude little gamestates (via HUMP.gamestate) which I can transition between (menu -> "game"). You can see what I have so far in the .love file attached to this post.
Before I go much further on defining the other gamestates, I want to learn how to make a neater ("juicier", I guess) transition between the two states I have. The transition effects I want to mimic are based on one of my favorite games of all time, The King of Fighters '98. You can see examples of the effects I want to implement in the first 5 seconds of this video:
https://www.youtube.com/watch?v=dbemtYemrFA
I dunno the proper animation terms to describe them, but there's a quick fade to white, and then what I guess is a "convergent wipe"(?) as two black rectangles quickly converge on the vertical center of the screen, blacking it out. Those are the two effects I want to implement and combine for my transition.
My forum search regarding screen transitions obviously brought up Chroteus' Venus library, but it doesn't look like Venus offers quite the transition effects I'm looking for. (Venus's fade only goes to black, and I dunno if I can combine multiple Venus wipes to get my desired "convergent blackout".) So I want to roll my own transitions, which I don't think looks very difficult to do. (I could very well be wrong.)
And so instead of asking you guys to write it for me, I'm gonna explain my naiive interpretation of how I'd do it, and you guys can clear up what's wrong with my interpretation, suggest stuff I should read to better understand my problem/solutions(that I'm not already Googling as I wait on replies), etc. I'll start just by thinking about the fade to white, since it seems the simpler of the two:
Fade to white:
On current state exit...
Non-looped, performed once initially:
Initialize a variable "alpha" to 0, to represent the opacity of a rectangle that will serve to fade out the screen contents.
Set the LOVE primitive drawing color (love.graphics.setColor()) to (255, 255, 255, opacity). This will make the fade rect be completely invisible (transparent) when first drawn.
Looped every frame, until alpha reaches 255:
If "alpha" is less than 255, then add some value to "alpha". (This rate of change has got to be tied to dt somehow, but I can't identify the exact logical relationship yet.)
Draw a filled LOVE rectangle primitive (love.graphics.rectangle()) at 0,0 across the whole width and height of the screen. As the loop turns over and the rect gets redrawn, it'll get more and more opaque until it's completely white.
Once "alpha" reaches 255, I want to end the transition and enter the next game state.
These are the major questions I'm asking myself right now:
- Do transitions merit their own HUMP gamestate? If so, do I want to push & pop them, or would it be more appropriate to enter & leave them? (e.g.: menu -> transition (-> another transition) -> gameplay) My gut says enter & leave might be most appropriate, because then I can use update & draw inside the transition to loop my opacity changes, and then switch to the desired next state (passed in as a param somewhere) upon achieving the exit condition. Am I on the right track?
- How must dt affect the rate at which I change the opacity? I'm almost positive it must be incorporated, because otherwise the amount of time taken to reach alpha=255 -- and thus end the transition -- will not be constant across different hardware. (If you have recommended readings on the different applications of dt in gamedev, I'm certainly not above stopping to read them. My math is crap & I'm trying to improve it.) Maybe I need to start a timer upon entering the transition and exit only when a certain amount of time has passed? But if so, I still need to relate the alpha change to dt, so that I'm not "spinning my wheels" if some machines reach full white faster than others simply by looping faster while adding a constant amount.
- Do I have a more efficient alternative to change the fade rect alpha than spamming setColor()? Does it matter for something this simple?