GetGUIObjectAt ?

Started by Ben, Sun 15/08/2004 22:17:45

Previous topic - Next topic

Ben

So...

I'm working on a new GUI for my game. I'll be using a verb coin with about four or five different actions (still haven't decided yet).

I'd like to have a lebel in the middle of the verb coin that acts as a mouse-over text. It tells the name of each button that the cursor is on..

The problem is that the text only shows up for one of my buttons (button 3). The others don't display anything.

Here's the code I'm using (all in the global repeatedly_execute):

Code: ags

  //If mouse is not over a hotspot...
  if(GetLocationType(mouse.x,mouse.y)==0) {
    if(GetGUIAt(mouse.x,mouse.y)==COIN){
      if(GetGUIObjectAt(mouse.x,mouse.y)==0) SetLabelText(COIN,4,"look"); 
      if(GetGUIObjectAt(mouse.x,mouse.y)==1) SetLabelText(COIN,4,"talk");
      if(GetGUIObjectAt(mouse.x,mouse.y)==2) SetLabelText(COIN,4,"push");
      if(GetGUIObjectAt(mouse.x,mouse.y)==3) SetLabelText(COIN,4,"climb");
      else SetLabelText(COIN,4," ");
    }
  }


This should change the text on label 4 when the mouse is over the buttons, and clear the text when the mouse is on nothing. Instead, it only displays the "climb" text when the mouse is over that button. Any ideas?


EDIT:

Also, one more unrelated thing:

For some reason, if I have a sound set to play in a loop at frame 0, I don't hear anything. I know it worked on an earlier version of AGS, though. Is there a reason why this has changed?

Darth Mandarb

I would be very interested in the answer to this as well ... as I'm working on something similar.

** dm waits in anticipation **

Proskrito

you should go:

if(GetLocationType(mouse.x,mouse.y)==0) {
    if(GetGUIAt(mouse.x,mouse.y)==COIN){
      if(GetGUIObjectAt(mouse.x,mouse.y)==0) SetLabelText(COIN,4,"look");
      else if(GetGUIObjectAt(mouse.x,mouse.y)==1) SetLabelText(COIN,4,"talk");
      else if(GetGUIObjectAt(mouse.x,mouse.y)==2) SetLabelText(COIN,4,"push");
      else if(GetGUIObjectAt(mouse.x,mouse.y)==3) SetLabelText(COIN,4,"climb");
      else SetLabelText(COIN,4," ");
    }
  }

otherwise, it would check all the 'ifs', then reach to the one that checks if its button 3, and if its not, (which is the case if you are in button 2, for example), put the empty line in the label
I hope i made sense : )

Darth Mandarb

** dm slaps himself with a herring **

That's so frickin' obvious!!

Thanks Proskrito.

Phemar


Quote from: Ben on Sun 15/08/2004 22:17:45
For some reason, if I have a sound set to play in a loop at frame 0, I don't hear anything. I know it worked on an earlier version of AGS, though. Is there a reason why this has changed?

I'm having exactly the same problem! AGS won't compile my sound effects and keeps on saying "Cannot load sound 0."
I don't know if this is AGS or just me, but can someone please answer this one?

No I'm not using a BETA version.

Ben

#5
Fanks!

Heh.. It seems kind of obviouse now. I guess Id betterl scurry away...

Zor: I think your problem is different from mine. I'm trying to put a frame sound in a loop.. at frame 0. If I read your post correctly, you're trying to use sound0, which you're not supposed to do anyway (0 means no sound in the scripts.. it can be used for music, though).

Gilbert

Well music0 is supposed to be played automatically if exists, when you start a game, so it's also not advisible to use it either if you don't want the game to behave like that.

But I agree that there're at times, quite obvious things that we overlooked (though I think that mistake was too obvious for you, Ben ;D ). I remembered once I had my game generated a warning like "Warning: cannot find sound5.wav", but I didn't put in any sound and any reference for playing sound files, I was all crazy about it as I couldn't find the glitch, so I nearly posted here for help, luckily before that I suddenly found out that you can now set sound associated to frames in views, that I wanted to give a frame a delay of 5 but somehow accidentally clicked "sound"...

Phemar


It has nothing to do with how I number my sounds, AGS just plainly refuses to play them.

Quote from: Warnings.log on Mon 16/08/2004 05:31:13
(in room 4): Sound sample load failure: cannot load sound 1

Gilbert

What format did you save your sound files in?
If they're of the .WAV format they must not be compressed.

Phemar


Err probably. But how to compress them?

P.S. Sorry ben for posting in your topic   :'(

PP.SS Is there a smaller or better format than wave sounds for your game?

Darth Mandarb

Yeah, convert them to mp3 or ogg.

Ben

Check out http://www.vorbis.com/ for some good OGG encoders (OGG is better quality than mp3).

And don't worry about posting in my topic.. Your problem was kind of similar to mine, so I'm not going to freak out or anything  ;)

Phemar


Thanks it works okay now.

Now I'm just upset because my .wav was 3kb and my .ogg file is 10kb...

You can't win can you?

Ben

What format was the WAV before you made it an OGG? Seems to me it would only get bigger if it was an extremely low quality wav (like 8-bit, 8000khz) to begin with, or if the file was already compressed using a different method..

Ishmael

You are probably converting it to a bigger bitrate, stereo from mono, or something. Check the .wav's protopies (atleast the sound recorder that comes with windows can to this, I think) and convert it to an .ogg of the same "volume".
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Darth Mandarb

Sorry to dig up an old thread but I finally got around to implementing this and I'm having some problems.

What I want to have happen is that when you move your cursor over the GUI button, it'll change another button's picture.Ã,  So if you mouseOver the walk icon (in the GUI) it'll change the middle button's graphic to say 'Walk' instead of its default state.

Here's my code:
Code: ags
Ã,  Ã,  if (GetLocationType(mouse.x, mouse.y) == 0) { 
Ã,  Ã,  Ã,  if (GetGUIAt(mouse.x, mouse.y) == MAINGUI) { 
Ã,  Ã,  Ã,  Ã,  if (GetGUIObjectAt(mouse.x, mouse.y) == 5) SetButtonPic(MAINGUI,8,1,43);
Ã,  Ã,  Ã,  Ã,  else if (GetGUIObjectAt(mouse.x, mouse.y) == 0) SetButtonPic(MAINGUI,8,1,42);
Ã,  Ã,  Ã,  Ã,  else SetButtonPic(MAINGUI,8,1,42);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  }


This seems to me to be what I was looking for, however, when I mouseOver the GUI objects, nothing happens.

If I click on a GUI object (walk), the GUI closes (as it's supposed to) and if I reopen the GUI, the middle button's pic has changed to say 'Walk'.Ã,  So it IS changing the button's pic ... just not when I want it to.

Is there a way to do this as a 'mouseOver' effect?

What have I tried?

I tried removing the IF statement checking to make sure you're in the MAINGUI because it takes up the whole screen so I figured I didn't need that.Ã,  It didn't error, but it still didn't work.

I tried using a Label instead of a button.Ã,  Same effect as above, changed on the click, but not the mouseOver.

I tried changing the IF statement to reflect another button rather than 0 or 5 and got the same effect as above.

Anyhelp would be much appreciated!Ã, 

Thanks!

Bernie

I tried your code, and it seems to work fine for me.

Hmm... is your GUI a popup modal (or blocking) one? If it is, try Repeatedly_Execute_Always.

Darth Mandarb

Yep!  That did it!  (putting it in the rep_ex)

Thanks bunches Bernie!


SMF spam blocked by CleanTalk