[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
Butterscotch Shenanigans Forums • View topic - GameMaker - draw_text with touch input

GameMaker - draw_text with touch input

Talk about anything and everything game dev-related here!

User avatar
Posts: 570
Location: Cracow, Poland

You may need to use the GUI size functions first to establish the pixel dimensions of your GUI.

User avatar
Posts: 1371
Location: St. Louis, Missouri, USA

I dit earlier.
Finally I made menu creating object without sprite for every menu button. But I hoped that I don't have to create so many objects.

User avatar
Posts: 570
Location: Cracow, Poland

Bit late to the party, but anyway...
You could get along with a single menu object but you would have some stuff to do with code.
1. drawn text can't react on input events so the menu object has to do that for you. Because the menu object has no sprite or the sprite doesn't necessarily cover all drawn menu items you have to listen to global mouse released events with your menu object.
2. You need to store the x,y and width,height values for all your drawn menu texts which you should do in the create event action. You might also want to use some functions to calculate width and height of the menu texts for the font you are going to use. GM:S has some builtin functions for that. So decide if you want to have different widths and heights for your menu texts or always same (maximum values of the individual text widths/heights) values for all menu items. Store x, y, width, height in an array. Store the menu texts in another or the same array with identical indices.
3. In your step event you could check if the mouse coordinates match one of your menu item text rectangles and set some mouse over flag (the array again) for the detected menu item.
4. In your draw event draw the menu items using your stored coordinates and smart usage of the halign/valign flags.
5. Trigger the desired actions in the global mouse left released event for the detected menu item. I suggest scripts for the actions to be executed.

I hope you got the idea.
You can even improve that menu object by using parenting and make a general menu object and each menu you use ingame is a child of your generic menu object. Of course you somehow need to prepare the array of menu text strings and the proper execution scripts in your child's menu create event and properly use event_inherited().

It's not basic stuff but it's surely doable ;)

User avatar
Posts: 3
Location: Elmshorn, Germany

Return to Game Dev

Who is online

Users browsing this forum: No registered users and 2 guests