EzMenu Documentation

Setting Up

Importing EzMenu into your project

Via Marketplace:
Import the project from the library screen, items in the demo folders are optional

Drag the .YYMP file onto the workspace area of your project. Items in the demo folders are optional

Basic Usage

At the beginning of you game, run this code

  • menu_create("main_menu");
  • menu_add_label("Hello EzMenu", -1); //-1 uses the gamemaker default font!
  • open_menu("main_menu");
  • Now run your game, you should see a menu appear.

    Adding Items to your Menu

    EzMenu comes with many scripts to easily add stuff to your menu.
    See the scripts under Scripts->EzMenu->Menu
    Simply call these menu_add_* scripts to add elements to your menu.

  • menu_create("main_menu");

  • menu_add_image(sDemoGameTitle, 1);
  • menu_add_gap(15);
  • menu_add_button_text_script(0, "Start Game", fnUiLarge, start_game, []);
  • Configuring EzMenu

    EzMenu offers a decent amount of customization right out of the box, the configuration script is located at Scripts->EzMenu->EzMenuConfig

    You may also wish to create your own component draw scripts or modify the existing ones located at Scripts->EzMenu->Component->draw This will help EzMenu fit your game's aesthetic.

    Custom Components

    Creating a Custom Component

    You can add your own components. See the menu_add_* scripts under Scripts->EzMenu->Menu to see some examples.

    Let’s create an image button that will link to another menu. Let’s create an empty script called "menu_add_button_image_link"

    Since EzMenu already contains a text button (Scripts->EzMenu->menu->menu_add_button_text_link) have a look at the code for that to get an idea of what we’ll be creating.

    We need 3 things for our image button.

    The index is used for gamepads to know which element to go to next as well as some internal logic for selecting menu elements.

    If a component has an index of -1, it can not be selected. Since out image button will need to be clicked, we need to give each one a unique index. Like the text button, we will make this the first parameter for our script

  • var index = argument0;
  • Our image button will need a sprite, let’s make that the second parameter and then the scale as the third

  • var index = argument0;
  • var sprite = argument1;
  • var scale = argument2;
  • With this info, we can work out the size for the component on the menu

  • var index = argument0;
  • var sprite = argument1;
  • var scale = argument2;
  • var size = sprite_height(sprite) * scale;
  • The next thing we’ll need is the menu to link to. This will be our next parameter.

  • var index = argument0;
  • var sprite = argument1;
  • var scale = argument2;
  • var menu = argument3;
  • var size = sprite_get_height(sprite) * scale;
  • Now onto the most important part, creating our component.

    A component is made up of an array with specific information

    EzMenu comes with a script to draw a sprite as a menu element, it’s under Scripts->EzMenu->component->draw and it’s called "draw_component_sprite"

    We can simply use that in our component array.

  • var comp = [draw_component_sprite];
  • Next we need our activate script, once again, EzMenu comes with one of these that will open another menu. Scripts->EzMenu-component->activate. It’s called "activate_component_link"

  • var comp = [draw_component_sprite, activate_component_link];
  • Now we’re just missing one thing, our script inputs. Opening up draw_component_sprite, we see that it needs two inputs, the sprite & scale. We’ll add theseas an array to our component array like so:

  • var comp = [draw_component_sprite, activate_component_link, [sprite, scale]];
  • Next, the inputs for activate_component_link, opening that script shows it simple needs a menu name to open. Let’s add it

  • var comp = [draw_component_sprite, activate_component_link, [sprite, scale], [menu]];
  • Now we have our component completed, we can add it to our menu.

  • menu_add(index, comp, size);
  • All together, it should look something like this:

  • var index = argument0;
  • var sprite = argument1;
  • var scale = argument2;
  • var menu = argument3;

  • var size = sprite_get_height(sprite) * scale;

  • var comp = [draw_component_sprite, activate_component_link, [sprite, scale], [menu]];

  • menu_add(index, comp, size);
  • Now to test our component.
    Go to your menu initialization point and test it out! Here’s an example:

  • menu_create("menu_main");

  • menu_add_button_image_link(0, sMyCoolButton, 2, "test_menu");

  • menu_create("test_menu");

  • menu_add_button_image_link(0, sMyCoolButton, 3, "menu_main");

  • open_menu("menu_main");
  • If all is well, you should have two different menus with image buttons on them!
    You can create your own draw_ or activate_ scripts as well, look at the default EzMenu scripts for inspiration and explanation.

    Component Draw Scripts

    Components ALL have a draw script attached to them, this is what draws them onto the menu. You can use the built-in scripts or create you own.
    The built-in draw scripts are located at EzMenu->Component->Draw, look at or modify these to learn more about how they work.
    Every component is passed the following parameters at draw time:

    Component Activate Scripts

    Every component has an "activate" script that is fired when an input is pressed while a component is selected.
    There are 5 types of input, defined via the eInputType enum.

    Components are passed the following parameters when one of these inputs is pressed See the scripts contained at Scripts->EzMenu->Component->activate for examples

    Transition Animations

    EzMenu comes equipped with a basic menu animation system. By default, a slide animation is applied when you change menus.

    To create your own menu animation, create a child of parMenuAnimator and mark it persistent.

    To set your animator object as the animation used, open up the EzMenuConfiguration script and change the value of MENU_ANIMATOR to your animator object.

    See the oMenuAnimatorSlide to see how it works.

    Component Data Storage

    EzMenu contains some scripts that allow you to store the state of components, this is used in Sliders, checkboxes, selectors, etc.
    This data is not saved between sessions. If you wish to serialize the data, it is stored in a globalds_map called global.component_values .
    To save data to the storage system:

  • component_data_set(component_id, value);
  • To retrieve it:

  • var value = component_data_get(component_id);
  • There are some helper methods located at Scripts->EzMeniu->Component->data to make handling of more complex components easier.
    This system is not intended to be a perfect solution, you may wish to engineer your own.

    Input Management

    EzMenu has an easy to change input system that you can change or modify to fit into your game.

    Open up the oMenus object located at Objects->EzMenu and open the "Begin Step" method.
    In here you will see the checks for user input, simply change these to suit your needs.

    EzMenu also offers a simple solution to switch between Keyboard/Mouse input to controller input, this is located in the same place. Modify this to your needs.