Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

AutoUi for GameMaker

A UI system for GameMaker for responsive, dynamic interfaces in seconds · By ome6a1717

Controller support

A topic by PsychicParrot created 12 days ago Views: 49 Replies: 3
Viewing posts 1 to 3

Hi! I'm really loving AutoUI so far - it's lightyears ahead of what I've been hacking together in GM myself and very welcome for my current UI-heavy game project :)

If at all possible, I would really love to see some sort of video or a quick guide on adding controller support. I'm using AutoInput (another brilliant tool you've made!) but I'm not yet sure how I'll go about putting the two together. Once I've got my basic windows all up and working, it's something I'll need to look into, so if there was any kind of help from you on where to get started on this I'd be even more mega grateful than I already am!

Thanks for making this system - UI in GM is painful and this honestly makes it a LOT easier.

Jeff.

Developer

Really glad you're finding it useful, and thanks so much for the kind words!

I thought about doing a video regarding this since I had to figure it out in my recent game, but for now here is the method I used:

1. Create a 'select' index variable, radiogroup, and function in your object that creates the "structure" of your selection (in the create event):

radiogroup = auto_radiogroup();
select = 0; // the index currently selected
options = []; // we'll add this later
menu_option = function(_name) {
    var _btn = auto_button_checkable_center(120, 40, _name, font, bgsprite, false, radiogroup);
    return _btn;
};

2. Add all of your options

options[0] = menu_option("Start");
options[1] = menu_option("Load");
options[2] = menu_option("Quit");
// add to your main container

3. Then in the step event:

if control_is_pressed("down") {
    select = (select+1) mod array_length(options); // set to next index
    options[select].set_checked(true, true); // checks this button and unchecks the rest of the radiogroup
}
if control_is_pressed("up") {
    select = (select+array_length(options)-1) mod array_length(options);
    options[select].set_checked(true, true); // checks this button and unchecks the rest of the radiogroup
}
if control_is_pressed("select") {
    switch(select) {
        case 0: startgame(); break;
        case 1: loadgame(); break;
        case 2: game_end(); break;
    }
}

Obviously this is a relatively rudimentary version of this, but again - I might do a video going into further detail.

Now, if you're like me and need to display more than just a button (eg. you want to have the "container" selectable), for now, you can kind of hack this by using a button as the background (with text set to ""), and place that and all of your elements in a stack.

Hopefully that should point you in the right direction!

(+1)

Yes! This is perfect, thanks for the quick reply! 

I did wonder if there was a 'set_checked' function but wasn't sure where to look for it, tbh.

This is def. enough for me to get the basics up and running. Cheers!

Developer

Of course!


You can find the methods in the respective script file of each element (eg. auto_button's methods are in the AutoUiButton script file.)  They are definitely worth a look through, especially since depending on which code editor you're using, autocomplete can be quite finicky.