I have created some simple buttons for an Android game and wanted to run the idea/logic by the forum to get feedback. I have classes which have vars like:
Button Class
float x, y, width, height;
Rectanlge hitbox;
String event;
Touch Class
float touch_x, touch+y;
Rectanlge hitbox;
boolean handled;
Concept
A simple screen might have 4 buttons that are put into an array, when the screen is pressed the x and y are captured and handled set to false, I then loop the button array checking for intersects and if true set menu_action to the button.event and set handled back to true.
I would handle this event and set some other boolean or string to false or “” so I know that event has been handled. When handled is true there is no need to loop the button array.
I could use scene2D but it felt overkill for such a simple task and I should imagine it deals with inputs in some similar way, checking each button that is listening?
This does work in my app I would just like some pro’s or con’s of doing this, is this bad practice?