Best practice for miniature menus

Hello, What is the best way & best practice of creating a mini-menu at the mouse or wherever? Im creating a TowerDefense and I want to popup a menu when I select a tile. How do you usually build this sort of thing?

Thx

I’d probably just make it’s own scene and bring it to the top and make your selections and then send the scene to the back.

In addition to make them with scenes plugins can be used as well. One can write own plugin to do that.

However, I am not sure, if it is necessary not for your case, if a plugin can stop/pause/sleep the scene it is open from. That would be strange because if it stop/pause/sleep what is left to show/work something. I would like to know about that.

I haven’t built one before, but I’d probably approach it somewhat like this:

  • build a ContextMenu class that takes in a list of ContextMenuItems. the ContextMenu would be responsible for displaying the context menu items and calling their callbacks when they are selected
  • define the list of ContextMenuItems that each selectable tile should have
  • when the selectable tile is selected, create/show the ContextMenu for the tile’s ContextMenuItems

Maybe see https://rexrainbow.github.io/phaser3-rex-notes/docs/site/ui-menu/.

Do you mean to create a class extends Phaser. Scene?

Not necessarily. I’m saying create a JavaScript class to hold the responsibility of displaying the context menu and its items, and handle its interactivity. Whether that’s a class that extends a scene or not, or is a class that extends some type of gameobject or not, or doesn’t extend anything and holds all its data in instance variables, it doesn’t matter. This was just a suggestion on how to organize the logic.

Maybe I should have been more explicit that I wasn’t giving exact implementation details, but more of a suggestion on design.

I am also concerned about this. What are your thoughts about that point regarding opening modals, dialogs, menus etc over a game scene?