How to create a menu within a scene

doccharlie

  • Posts: 11
Hey guys. I fancy making a button that opens a menu within the scene with options that the player can click on, with a similar style to how an inventory work but with fixed options that are always there. Can you help me with the code that is necessary? I'm having difficulty already making the button work (The <When mouse is pressed down on [actor]> does not work as it will continue with the event even if I just lay my mouse on it without clicking). Thanks :)
Love to learn new things and am really open to suggestions :)

colburt187

  • *
  • Posts: 2416
Can you show example of the code your are trying. Are you sure you don't have the mouse block on "when mouse is over self"

squeeb

  • Posts: 1617
i use when mouse released to switch things..

doccharlie

  • Posts: 11
Can you show example of the code your are trying. Are you sure you don't have the mouse block on "when mouse is over self"
I think I sorted the mouse problem. I had it turn on a boolean variable before. And there were if statements in the scene events that created the actors if the variable was True, and kill them if it was False. I changed it to a custom block, for now, as that works, but as I'm uncertain of the code that is to come, it feels unsafe to use a custom block that only occurs rather than a variable that can be checked with an 'always' loop. If you have any suggestions, I would love to hear them. Attached is a pic of the event I use at the moment for my button. The variable I mentioned before is called 'Act', which stands for Actions. The custom block 'Open Actions Inventory' causes the scene to create the actors once.
Also thanks, squeeb, I'll try that as well.
Love to learn new things and am really open to suggestions :)

Itsmelee

  • Posts: 52
did you get it sorted ??

doccharlie

  • Posts: 11
Love to learn new things and am really open to suggestions :)

KramerGames

  • Posts: 405
what exactly is the problem? This is how I make menus:

add event--> input-->, which will give you this block:

when mouse is pressed

Now adding the block under user input "when mouse is down on" and change it to:

When mouse is pressed
-if mouse is over self
-- create the menu window


In case your making games that involve various types of windows, this method allows for more control.

I don't see exactly what could be the problem with your code, I suggest using a print event and put that under "when created" in the window actor, then you can see in the logviewer if the window was at least created (someplace, sometime).

One problem that I had when making windows was that you click the button to create the window and that very same click also counts as clicking something in the window. Was driving me nuts when the mouse was over a close window button so I didn't even get a chance to see it. For that I have a boolean in the window called "locked" and set it to true by default, and under a "when created" event I set it to false after 0.5 seconds. Anything that happens inside the window can only happen if locked is false.
Parasites United  (Idle Parasite Game)

merrak

  • *
  • Posts: 2739
My LD game has a popup menu, so if you want to see an example then here's a link to the source code. Feel free to use whatever code you find useful. The method used is pretty much the same as KramerGames'.

http://anorthogonaluniverse.com/flash/AetherMine.stencyl

You'll need the AI Tools Extension and Text Tools Extension to make it run. The extensions aren't necessary for the menu code, but Stencyl will complain that the extensions are missing.