Using the Widgets

Using the Widgets

Using the widgets (objects)

The design of the GUI framework is to minimize the number of objects to manage your game menu GUI. To use the objects you simply add them to your room and modify the create code. You do NOT modify the widgets directly or assign sprites to them like you would your normal game objects. For example, with the button widget, you assign uiButtonSprite=spr_yoursprite and the button widget will use that for drawing.
To access the widgets around your code you simply use the instance name. So in your room editor you can add a label, (use rename instance name to something like “lbl_gamer”) you can then change the text that gets displayed in code by using lbl_gamer.uiTextValue=’John Smith’; So you can modify any widget in code by using the instance_name.property syntax. Other examples would be: (set instance name in room for the listbox to : weapons)
Then we use this outside of the room editor:

 

weapons.items=0; //clear the list array
weapons.items[0]=’First weapon’;
weapons.items[1]=’Second weapon’;
weapons.items[2]=’Third weapon’;

Although using the room editor to visually place and setup the widget properties is great, sometimes you need/want to create them dynamically. You are not forced to use the room editor when using the widgets, you can create them and set their properties outside of the room editor.
For example:

with instance_create(100,110,ui_label)
{
uiTextValue=’This is a label’;
uiAlign=fa_center;
uiTextColor=c_yellow;
uiSetWidth=500;
uiFont=fnt_bigarial;}

 

You may also like...