Can a GUI Pushed Button image be set to transparency?

Started by newwaveburritos, Thu 25/02/2021 05:36:19

Previous topic - Next topic

newwaveburritos

So, I've got the a GUI payphone working how I want it to with the exception that I want the pushed buttons to appear pushed.  The background art for the GUI is all of the buttons pushed in and each individual button has its own sprite.  So, to get it to looked pushed I really just need the button to disappear when it's clicked but I can't seem to make this work.  I tried to set PushedImage in the editor to -1 but it doesn't like that.  I tried to set it manually with:

Code: ags

  Button1.PushedGraphic = -1;
  Button2.PushedGraphic = -1;


in game start but that doesn't work either.  I was hoping there was an easy solution that doesn't require me to cutout and line up all the keys again.  Thanks for any help! Here's the GUI code for reference:

Code: ags

function Dial(GUIControl *control, MouseButton button) {
  if (button != eMouseLeft){
    return; // only react to left clicks
  } 
 
  TextBox1.Text = TextBox1.Text.AppendChar(control.ID + 48);  // ascii code for 0: 48, 1: 49, etc
  
  TelephoneNumber++;
  if (TelephoneNumber == 7){
    TelephoneNumber = 0;
    Game.SimulateKeyPress(eKeyReturn);  //enters the textbox contents when it reaches seven digits.
    
    
  }
  
}

Khris


newwaveburritos

Quote from: Khris on Thu 25/02/2021 08:30:40
You need
Code: ags
  Button1.Visible = false;


I think what I'm missing is where to put that code so the button is not visible only when the button is pushed and reappears when the mouse click is released.  Something like:

Code: ags
while (IsButtonPushed == true){
  Button1.Visible = false;
}

Khris

I see, I assumed the button is supposed to stay pushed. Use a fully transparent sprite as PushedGraphic then.

newwaveburritos

Oh my lord, you're right.  All sprites are the same when they're transparent.  I was overthinking for sure.

SMF spam blocked by CleanTalk