Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Custom menu screen problems  (Read 2962 times)

0 Members and 1 Guest are viewing this topic.

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Custom menu screen problems
« on: April 08, 2007, 03:04:22 PM »

Again, I feel quite stupid. However, it's clear that I am not the only one having this problem, which gives me the courage to ask.

I want to bring up a custom menu screen when the escape key is pressed. I've borrowed a code snippet from the Mystic Triddle demo (see below).

When I paste the code into the game script everything works PERFECTLY FINE, except that when I am in the menu scene, and press escape again, it reloads the menu scene, instead of resuming the game. What makes this especially annoying is that when the menu scene has been reloaded, "Resume game" does not work, since it goes back to the previous scene, in this case the previous occurence of the menu scene.

In the Mystic Triddle demo, pressing escape when in the menu resumes game, BUT, in the Beyond the Threshold demo, in which the same method is used, the exact same problem occurs, that is when pressing escape in the menu, the menu reloads, and the game can't be resumed after that.

This is the code I've used:

Code: [Select]
////////////////////////////////////////////////////////////////////////////////
on "Keypress"
{
  // on Esc or F1 key
  if(Keyboard.KeyCode==VK_ESCAPE || Keyboard.KeyCode==VK_F1)
  {

  if(Scene.name == "menu")
  {
     if(Game.PrevSceneFilename == "")
      ;
     else
      {
  Game.ChangeScene(Game.PrevSceneFilename); // Go back to game - acts like resume game
  }
  }
  else
  {
  if(Game.SelectedItem!=null) // deselect Items if active
  Game.SelectedItem = null;
 
  //Game.ScreenshotEx("saves\temp.bmp",200,150);   // when we want to store a screenshot manually
  Game.ChangeScene("scenes\menu\menu.scene");      // load and display the main menu window
  }
   
  }
}

Thanks for any help!

Regards,

Mikael
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Custom menu screen problems
« Reply #1 on: April 08, 2007, 03:11:54 PM »

"Scene.name" should be Scene.Name. WME scripts are case-sensitive.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Re: Custom menu screen problems
« Reply #2 on: April 08, 2007, 03:25:15 PM »

Oh, thanks. Now it works fine.

Mikael
Logged
 

Page created in 0.038 seconds with 21 queries.