First, you need this piece of code:
This basically sets up an object that will act as the button. It will render the text as an image using the provided font when you create the object.
However, we need to load it together with the font using this piece of code: (Here ImmiExample is an earlier provided struct that will just be used as a container)
Here, we load font.ttf, make a style for it and then pass it all to Buttonstate so it can do its pre-render magic.
However, we are not there yet as we still haven't actually drawn anything. To do that we need this piece of code:
And all we have done now is create some text in the middle of the screen that says "normal button" when nothing is happening and "Hovered button" or "Clicked button" if you hover or clicked on it. It will also print "Test!" to the console when you click on it.
Also, if you want your assets to load before running the game you will need to implement that yourself. Luckily there is the "execute_or" method that takes 2 functions. One will run when its done loading when you call it and the other if you call it while it is still busy.