A menu of various items that can be rendered on screen.
new Menu(scene, config);
scene—SceneThe scene thisMenuis a part of.config—ObjectTheMenu's config object.x—numberThisMenuobject's x-coordinate.y—numberThisMenuobject's y-coordinate.items—Array<Menu.Item>An array ofMenu.Iteminstances. You can extend theMenu.Itemclass to make your own items.title—stringOptional menu title.alignCenter—booleanWhether or not to align the content to the center of the menu. Defaulttrue.border—booleanWhether or not to create a border around the menu. Defaulttrue.layer—stringThe label of the layer to start theMenuon.autoFocus—booleanWhether to automatically focus on theMenuafter it has been instantiated. Defaulttrue.maintainFocus—booleanForces the menu to stay focused. Defaulttrue.deleteOnBlur—booleanWhether to delete the menu when it becomes unfocused. Defaultfalse.gamepad—numberAn optional number indicating the gamepad (0-based index) this menu should accept input from. Set to-1to accept input from all gamepads.
The current gamepad index.
An array of Menu.Item instances that are part of the menu.
The title of the menu.
The index of the current item that is selected in the menu.
Handle input events to navigate and select options in the menu.
event—ObjectThe input event to handle.
Get the width of the menu.
numberThe width of the menu based on the longest option and title.
Get the height of the menu.
numberThe height of the menu based on the number of options.
Determine the length of the longest option label.
numberThe length of the longest option label.
Generate the renderable representation of the menu.
PixelMeshThe PixelMesh representation of the menu including options and title.
Unfocus the menu. If maintainFocus is true, the menu will not be unfocused.
Get an item at a y-coordinate relative to the menu.
y—numberThe y-coordinate to check.
Menu.Item|undefinedThe item at that coordinate, orundefinedif there is no item at the coordinate.
Base class for menu items, which can be extended to create custom items.
A string of text that triggers an event when clicked.
new Menu.Button(config);
config—ObjectTheButton's config object.label—stringTheButton's display label.callback—functionThe function to call when this item is clicked/activated.wrap—booleanWhether or not to wrap the text if it overflows the container. Will break words. Defaultfalse.
A slider that allows value selection.
new Menu.Slider(config);
config—ObjectTheSlider's config object.label—stringAn optionalSliderdisplay label.value—numberThe starting value of theSlider.min—numberThe minimum value for theSlider.max—numberThe maximum value for theSlider.step—numberThe amount the value will change by each input.onChange—functionThe function to call when the value of thisSliderchanges.callback—functionThe function to call when "enter" is pressed on theSlider. This callback is passed the currentMenu.Slidervalue as an argument.showValue—booleanWhether to show the value of theSliderafter it. Default:false.showPercentage—booleanWhether to show the value (in percentage format) of theSliderafter it. Default:true.
A checkbox that can be toggled on or off.
new Menu.Toggle(config);
config—ObjectTheToggle's config object.label—stringTheToggle's display label.checked—booleanThe initial status of theToggle. Default:false.prepend—booleanWhether to put the checkbox icon at the start or end of the label. Default:true.callback—functionThe function to call when this item is toggled.