Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: cAlien_Interact on Wed 10/02/2021 11:21:37

Title: Show picture when clicking on object (poster,newspaper)
Post by: cAlien_Interact on Wed 10/02/2021 11:21:37
This is the script (see below)that I have for a poster(object)in a room,
I want an image to pop up as I click on the poster,
how do I set it to show up and be able to click away from it once finished looking at it.


Code (ags) Select

function POSTER_Interact()
{
  aPaper.Play();
}


Thanks! :=
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: cAlien_Interact on Wed 10/02/2021 11:52:07
This is not what i'm looking for ;ShowPlayerCharacter - if checked, the player character will not be visible in this room, and the Walk mode will be disabled. Useful for close-up displays of control panels and so forth.
That would be a new room.
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: Matti on Wed 10/02/2021 12:06:05
Best way is to make a GUI with the picture of the poster and turn it visible/invisible.
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: cAlien_Interact on Wed 10/02/2021 14:11:38
Thanks,I tried this,


{gGui1.Visible = true;}

How do I make it disappear


Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: cAlien_Interact on Wed 10/02/2021 14:42:50
The image is there, and I adjusted where it shows up,
Just need to know, how to make it vanish, sorry i'm quite new to this program,
Thank for the help,I appreciate it!
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: Slasher on Wed 10/02/2021 16:30:01
Code (ags) Select

gGui1.Visible = false;
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: Cassiebsg on Wed 10/02/2021 16:41:58
You put the above code inside either a button, or on_click for the GUI, depending if you want it to be closed by clicking a specific place (button) or just anyclick on the GUI/picture will close it.
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: Matti on Thu 11/02/2021 17:17:43
If you want to make the GUI disappear if the player clicks outside of the picture you could check if the player presses a mouse button inside the room's repeatedly execute function:

Code (ags) Select

  if (gGui1.Visible && mouse.IsButtonDown(eMouseLeft)) gGui1.Visible = false;
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: cAlien_Interact on Thu 11/02/2021 18:17:56
Quote from: Matti on Thu 11/02/2021 17:17:43
If you want to make the GUI disappear if the player clicks outside of the picture you could check if the player presses a mouse button inside the room's repeatedly execute function:

Code (ags) Select

  if (gGui1.Visible && mouse.IsButtonDown(eMouseLeft)) gGui1.Visible = false;


trying,thx
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: cAlien_Interact on Thu 11/02/2021 18:36:23
Roomscript on the Object,
Code (ags) Select

function POSTER_AnyClick()
{
aPAPER.Play();
{
mouse.IsButtonDown(eMouseLeft);
gGui1.Visible = true;
}


}

with THIS on Globalscript:
Code (ags) Select

function gGui1_OnClick(GUI *theGui, MouseButton button)
{
if (gGui1.Visible && (button == eMouseLeft || button == eMouseRight)) {
    gGui1.Visible = false;
    return;
  }
}

And set them to Visible:False on Gui properties

I did it this way, but mabye I overcomplicated it?
What happens now is when I press my Object, the Gui(the image) pops up, and when the Gui(image) is clicked on it dissapears! Perfect..

Thanks for some help in the start
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: cAlien_Interact on Thu 11/02/2021 19:43:43
Is it possible to, have picture be displayed for like 1 second after it pops up,automatically closing?
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: newwaveburritos on Thu 11/02/2021 19:53:21
Yeah, you would just set a timer to start when you click on it, and then in repeatedly execute you would check to see if the timer has expired and then set gGUI1.Visible to false.
Title: Re: Show picture when clicking on object (poster,newspaper)
Post by: cAlien_Interact on Thu 11/02/2021 20:03:00
Quote from: newwaveburritos on Thu 11/02/2021 19:53:21
Yeah, you would just set a timer to start when you click on it, and then in repeatedly execute you would check to see if the timer has expired and then set gGUI1.Visible to false.

Will look into it, thx