Regarding the GUI buttons, I think it's really helpful having a GUI container, something like:
Ok. I've got the idea.
IMO as long as there aren't many GUI elements, up to 5 - 7, it is possible to go without containers.
On the other hand, in the part 3-16 on Final screen and Credits I have a code like
Code: Select all
function gamefinished.update( dt )
buttons_with_url.update_button( gamecode_button, dt )
buttons_with_url.update_button( love_button, dt )
buttons_with_url.update_button( vector_button, dt )
buttons_with_url.update_button( tileset_button, dt )
buttons_with_url.update_button( bungeefont_button, dt )
buttons_with_url.update_button( cmusounddesign_button, dt )
buttons_with_url.update_button( ngruber_button, dt )
buttons_with_url.update_button( bart_button, dt )
buttons_with_url.update_button( qubodup_button, dt )
buttons_with_url.update_button( tinyworlds_button, dt )
buttons_with_url.update_button( edgardedition_button, dt )
buttons_with_url.update_button( music_button, dt )
end
In this case, GUI containers really are convenient.
Ironically, GUI is an area where object-orientation is quite useful.
This makes the code slightly cleaner and will allow you to build upon it by introducing new types of elements:
I've run into this issue while defining `button_with_url` (it is similar to `button`, but has an associated url, which is opened on click). Instead of inheriting `button` I've simply copied most of the code. Probably, no the best solution, but it can be tolerated as long as it is not overused.
I agree that GUI containers should be mentioned somewhere.
I'll think on how to incorporate them into the tutorial.
Currently I opt to postpone this topic until part 3-16 on Credits and Final screen.
Also, make sure the "new_button" function accepts a filename so that you don't have to pass around quads and other internal objects.
I can't see the point. What do you mean?
If I use a single image file for different buttons, I have to tell a button constructor which part of the image to use.