Saturday, May 15, 2021

Back and Forth

 

Thought using Hump's Gamestate switch function would be easy.

Actually it is, but it took a day of tweaking to get there. Enough about

me...


The aim here is to start fom one gamestate: menu, move to the other:game, 

and then back to menu. Below, the Gamestate starter form Hump documentation:





Yes, one can go back and forth, but Love won.t let me go back to the menu:draw().

that would be a duplicat function. So it is forward to new levels...



                                                                 *     *     *

The code works with gamestates initiated as empty tables. Hump/gamestate.lua has the

code which instructs gamestates to register events. The documentation also

mentions that one can restrict which events one wants to register, from 

Gamestate.registerEvents().




A callback and an event are not - strictly speaking - the same thing. An event

is user-generated and in turn triggers a callback. A callback itself is a function

passed as an argument to another function. Love itself has to keep track

of all callbacks.



In switching between states, one is going from one memory stack to another...

No comments: