Skip to main content

News

Topic: Menu tutorial issue (Read 226 times) previous topic - next topic

Re: Menu tutorial issue
Reply #15
one more question about this menu

I have been trying to use BindKey(KEY_TILDE, "", "");
to access the menu. I have tried a few different methods but with no real success. I have used BindKey for other functions such as
DebugXY: returns the players current x,y values
DebugLayer: returns what layer the player is currently on (found very useful when i was creating my raft function and the player suddenly stopped moving)
DebugPlayer: which returns the variables for the player. hp, items, currency etc...

all of which function the way they are designed to. However, attempting to bindkey this menu is not functioning. Any suggestions?
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Rhuan
  • [*][*][*][*]
Re: Menu tutorial issue
Reply #16
From a quick glance back at your code I can't see a function you could call to run that menu, it's the second half of your game function after the MapEngine() call which means the code won't be evaluated until the MapEngine has ended.

You need to break the menu out into its own function:
Code: [Select]
function gameMenu()
{
  var myMenu = new Menu();
  myMenu.addItem("Item 1", "Item 1", Exit);
  myMenu.addItem("Item 2", "Item 2", Exit);
  myMenu.addItem("Item 3", "Item 3", Exit);

  myMenu.preRender = function()
  {
    if (IsMapEngineRunning())
    {
      RenderMap();
      UpdateMapEngine();
    }
  }

  myMenu.execute(GetScreenWidth()/2-80, GetScreenHeight()/-40,160,80);
}

Then BindKey(KEY_TILDE, gameMenu, ""); should work. Note the above function will need to be defined globally (i.e. not inside the game function) in order to be reachable by the mapengine.

Re: Menu tutorial issue
Reply #17
You need to break the menu out into its own function

I'll give that a try. I appreciate the feedback.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity