Game Development Community

Changing a button bitmap upon mouse rollover.

by Braveheart · in Torque Game Engine · 03/18/2008 (5:15 pm) · 1 replies

Hey!

How can I get the GUIBitmapButtonCtrl to change to another bitmap upon rollover and/or click? Would I add a command into the command line?

(Such as "mouse.rollOver, set.image=("imagename"))

Obviously that but in Torque Script which I have yet to learn! I have been focusing on PHP, HTML and MYSQL for the past few days, so.

Also an off topic question: if I add a new GUI file (saved with extension .gui) into the ui folder, one it doesn't show up in the folder, two it doesn't show up in the F10 menu in-game. If I copy another already existing one, the same two problems occur. Any ideas?

Anyway, please do help!!

Thanks,
Robbie.

#1
03/18/2008 (5:50 pm)
Here's one way:

Make two versions of your button - one for how the button appears normally, and one for how it appears when it's highlighted. For this example, my button is called "play"

Name the normal version "play_n.png" (or .jpg whichever you are using)
Name the highlighted version "play_h.png" (or .jpg)

In the script for the button, you have code similar to this:

new GuiBitmapButtonCtrl(Playbutton) {
      canSaveDynamicFields = "0";
      Profile = "GuiBorderButtonProfile";
      HorizSizing = "right";
      VertSizing = "top";
      Position = "37 122";
      Extent = "200 70";
      MinExtent = "8 2";
      canSave = "1";
      Visible = "1";
      tooltipprofile = "GuiToolTipProfile";
      ToolTip = "Enter the world";
      hovertime = "1000";
      text = "Button";
      groupNum = "-1";
      buttonType = "PushButton";
      bitmap = "./buttons/play";
   };

Notice in the bitmap property, you just use the "play" portion of the name. Torque automatically finds the _h and _n versions to use them properly.

This is how I made these menu buttons:

http://i275.photobucket.com/albums/jj285/OldRod_Dev/ah_menu.png