Show picture when clicking on object (poster,newspaper)

Started by cAlien_Interact, Wed 10/02/2021 11:21:37

Previous topic - Next topic

cAlien_Interact

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

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


Thanks! :=

cAlien_Interact

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.

Matti

Best way is to make a GUI with the picture of the poster and turn it visible/invisible.

cAlien_Interact

Thanks,I tried this,


{gGui1.Visible = true;}

How do I make it disappear



cAlien_Interact

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!

Slasher


Cassiebsg

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.
There are those who believe that life here began out there...

Matti

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

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

cAlien_Interact

#8
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

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


trying,thx

cAlien_Interact

#9
Roomscript on the Object,
Code: ags

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


}

with THIS on Globalscript:
Code: ags

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

cAlien_Interact

Is it possible to, have picture be displayed for like 1 second after it pops up,automatically closing?

newwaveburritos

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.

cAlien_Interact

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

SMF spam blocked by CleanTalk