Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Draco

#1
There are two buttons which doesn't work:
1.Start
2.Intro text
When I click on them I just get to the menu again.And If I use the load button and cancel it I'm on the page with intro text. I used This code:

function Button1_OnClick(GUIControl *control, MouseButton button)
{
player.ChangeRoom(2);
}

function Button2_OnClick(GUIControl *control, MouseButton button)
{
  gMainMenu.Visible=false;

  gRestoreGame.Centre();         
  gRestoreGame.Visible=true;
}

function Button3_OnClick(GUIControl *control, MouseButton button)
{
player.ChangeRoom(3);
}

function Button4_OnClick(GUIControl *control, MouseButton button)
{
QuitGame(1);
}


Rooms are:
1.room with menu
2.Starting place
3.Intro text

#2
As you can see, my biggest problem is making menu. Can you tell me any code to make menu? I need 4 things:
1.Start a new game
2.Load game
3.Show intro text (I planned this like another room, but if you have better idea just tell me)
4.Exit
So, could you tell me?
#3
I have written the code for global script to script for the menu room  in "aplication funcions" part and guess what? The problem was still there: mouse in walk mode, black squares instead of iconbar and when i click on the square when normaly is quit game button the mouse change to a pointer so the first part of the problem is solved (maybe) but I can't click to any of the menu buttons.
This is the code for menu buttons I've used (they are in global script) :

// Menu Gui
//
// The  following functions are executed in  response to mouse clicks
// on the Main Menu that appears at the beginning of the game.
//-------------------------------------------------------------------
function gMenuIntro_Click(GUIControl *control, MouseButton button) {
   player.ChangeRoom(3); 
}

function gMenuLoad_Click(GUIControl *control, MouseButton button) {
   mouse.Mode = eModeWalkto;
   RestoreGameDialog();
}

function gMenuPlay_Click(GUIControl *control, MouseButton button) {
   player.ChangeRoom(5);    // player is now updated when PC changes
}

function gMenuQuit_Click(GUIControl *control, MouseButton button) {
   player.ChangeRoom(4);
}

#4
Quote from: Snarky on Fri 16/09/2011 15:36:38
OK, Khris posted first, but this could still come in handy.

Quote from: Draco on Fri 16/09/2011 15:09:25
Maybe I'm stupid or the AGS hates me, I really don't know.

You're probably just not that experienced when it comes to programming. Find the part of the file that says something like:

Code: ags
function repeatedly_execute() {
  // stuff...
}


Take the code you have and move it inside that function, so it looks like this:

Code: ags

function repeatedly_execute() {
  GUI*um = GUI.GetAtScreenXY(mouse.x, mouse.y);  // GUI currently under mouse
  if (um != under_mouse) {  // mouse moved over or off GUI
    if (under_mouse != null) {
      // mouse was moved away from GUI under_mouse
      if (under_mouse == gMenu)
        mouse.Mode = eModeWalk;
    }
    else {
      // mouse was moved over GUI um
      if (um == gMenu)
        mouse.Mode = eModePointer;
    }
  }
  under_mouse = um;
  // stuff...
}


Make sure you don't change anything else that is in the function (the bit I call "// stuff..."). The way it works is that the "{ ... }" brackets define a block, and when that block follows a function declaration (a line that begins with the word "function"), it means "run this block of code any time the function is called". But if the block is just there by itself, AGS doesn't know what to do with it. The function "repeatedly_execute" is special in that AGS automatically calls it every game cycle, so anything you put in that function happens every time the game updates.

OK, I've removed the code from the room2 (the room with menu) and the code with you said to me I have put in the right part of global script. Than it said: undefined symbol "under_mouse".
#5
Quote from: Khris on Wed 14/09/2011 17:38:53
Did you put the second block inside the repeatedly_execute function, i.e. between its { and } ?
OK, I forgot about that. Now the code is:
//====================================================================
//Repeatedly_execute:
//-------------------------------------------------------------------
GUI*under_mouse;

{GUI*um = GUI.GetAtScreenXY(mouse.x, mouse.y);  // GUI currently under mouse
  if (um != under_mouse) {  // mouse moved over or off GUI
    if (under_mouse != null) {
      // mouse was moved away from GUI under_mouse
      if (under_mouse == gMenu) mouse.Mode = eModeWalk;
    }
    else {
      // mouse was moved over GUI um
    if (um == gMenu) mouse.Mode = eModePointer;
    }
  }
under_mouse = um};
But it says there is unexpected { in this line:{GUI*um = GUI.GetAtScreenXY(mouse.x, mouse.y);  // GUI currently under mouse

Maybe I'm stupid or the AGS hates me, I really don't know.
#6
Quote from: Khris on Tue 13/09/2011 17:35:50
This should work:

above repeatedly_execute:

Code: ags
GUI*under_mouse;


inside it:

Code: ags
  GUI*um = GUI.GetAtScreenXY(mouse.x, mouse.y);  // GUI currently under mouse
  if (um != under_mouse) {  // mouse moved over or off GUI
    if (under_mouse != null) {
      // mouse was moved away from GUI under_mouse
      if (under_mouse == gMenu) mouse.Mode = eModeWalk;
    }
    else {
      // mouse was moved over GUI um
      if (um == gMenu) mouse.Mode = eModePointer;
    }
  }
  under_mouse = um;


I have tried it, but it says "cannot assign initial value to global pointer" to this part:
GUI*um = GUI.GetAtScreenXY(mouse.x, mouse.y);  // GUI currently under mouse
#7
Hi,
I have this problem:
I want to make a menu for my game (when I'll finish it I'll upload it).
So I want to hide "Iconbar" and have cursor like a pointer.
I've tried this code for it:
function MenuRollDown() {
   Flag++;
   if ((55<Flag)&&(Flag<150)) gMenu.SetSize(320, (Flag-50)*2);
}

function MenuInit() {
   gMenu.SetSize(320, 1);
}

function MenuOn() {
   gMenu.Visible = true;
mouse.UseModeGraphic (eModePointer);
 gIconbar.Visible = false;
}

function MenuOff() {
   gMenu.Visible = false;
   mouse.UseModeGraphic (eModeWalkto);
 gIconbar.Visible = true;
}
So the problem is like this: when i start the game the cursor is in Walkto mode and I can't click on the menu buttons. I just want to have the cursor in pointer mode.
Is there any solution? ???

Draco
#8
Oh, I forget to say I'm new here.
#9
Hi,
I have a little problem.
I have started one game and I wanted to spare some time so I used the code from the Demo game (I hope it doesn't matter ???). Of course I changed the code a little bit, after the change the code is:
function room_c() {
   // script for room: Repeatedly execute
   if (FadeToBlack()==false) {
      SetScreenTransition(eTransitionDissolve);
      player.ChangeRoom(Menu.crm);
    }

So I have two problems; first one: in the original code it was it was like: player.ChangeRoom(crmMenu);
and when I copied it the AGS said its "unknown token:crmMenu" so I tried to change it a little bit and it has disapper. But I don't know if its right. The second problem is that the AGS say that in the last part of the problem code  (player.ChangeRoom(Menu.crm); ) is expected semicolon. But the semicolon is already there.
Could you help me?

Draco
SMF spam blocked by CleanTalk