Positioning image on button and remove greying out

Started by Ghostlady, Mon 31/03/2008 04:10:58

Previous topic - Next topic

Ghostlady

I am trying to create a gui that pops up when an inventory item is picked up, and the gui displays the item.  Based on this post:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=28748.0

I've created the button and the gui.  All is working but the inventory item is greyed out and not centered.  How do I fix this? 

My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

TwinMoon

It is greyed out because the game is paused.

Under 'General settings' go to Visual and change the 'When player interface is disabled, GUIs should'  to Display Normally.

You can set the position of the GUI opening the GUI in the editor and change the values of TOP and LEFT in the properties window (in the bottomright).

Also, you in the global script under game_start you could put:
Code: ags
GUI1.Centre;

(where GUI1 is the name of your gui)

That will centre it automatically.

Ghostlady

Okay, I'll try that.  I need to center the inventory item graphic to the middle of the button though, not centering the gui.  Is that possible?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

TwinMoon

Ok, that's a different story.

Quote from: Ghostlady on Mon 31/03/2008 13:32:33
I need to center the inventory item graphic to the middle of the button though, not centering the gui.  Is that possible?

No. Not directly anyway.
The way to do this is to make the images you'll use on the button the same size as that button.
In the paint program you use, resize the canvas of your image so it's the same size as the button. Then center the image.

SSH

Or you can use the size of the image to dynamically reposition the co-ordinates of the button.

Code: ags

YourInvButton.X=(MAX_IMAGE_WIDTH-Game.SpriteWidth[player.ActiveInventory.Graphic])/2;
YourInvButton.Y=(MAX_IMAGE_HEIGHT-Game.SpriteHeight[player.ActiveInventory.Graphic])/2;
12

Ghostlady

Ah SSH, that's what I was looking for.

Thanks for you help TwinMoon, the gui is no longer greyed out.
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

TwinMoon

Quote from: SSH on Mon 31/03/2008 17:30:13
Or you can use the size of the image to dynamically reposition the co-ordinates of the button.

Code: ags

YourInvButton.X=(MAX_IMAGE_WIDTH-Game.SpriteWidth[player.ActiveInventory.Graphic])/2;
YourInvButton.Y=(MAX_IMAGE_HEIGHT-Game.SpriteHeight[player.ActiveInventory.Graphic])/2;

Ah, I spoke too soon. Live and learn.

Ghostlady

#7
Explain to me about MAX_IMAGE_WIDTH and MAX_IMAGE_HEIGHT.  I am not finding it as valid code or a reserved word. 
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Ghostlady

Okay, I got it to work using this.  Cool...

      popupinv.X=(42 - Game.SpriteWidth[inventory[data].Graphic])/2;
      popupinv.Y=(26 - Game.SpriteHeight[inventory[data].Graphic])/2;

It places the inventory item right in the middle of the gui without ever having to switch images....

Very cool.. Thanks.
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

SMF spam blocked by CleanTalk