Jump to content

onClientMouseEnter


papam77

Recommended Posts

Hello, how can make alpha changing if i enter with mouse to my image?

 lobby = guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "images/lobbyBG.png", true)     
    arenas = guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "images/arenas.png", true)     
    dm = guiCreateStaticImage(0.157, 0.19, 0.17, 0.305, "images/areny/dm.png", true, arenas)  
    dd = guiCreateStaticImage(0.331, 0.19, 0.17, 0.305, "images/areny/dm.png", true, arenas)  
     
     
     
     
     
     
     
    guiSetAlpha ( dm, 0.75 ) 
    guiSetAlpha ( dd, 0.75 ) 

This is code for images alpha must be 1.00 if player enter to the button.

How can do that?

Link to comment

Use the event onClientMouseEvent, and when the mouse is over the specified GUI Element it will trigger the function, for example;

function onClientMouseHoverSetAlpha() 
    if(source == dm) then 
        guiSetAlpha(dm, 0.75) 
    elseif(source == dd) then 
        guiSetAlpha(dd, 0.75) 
    end 
end 
addEventHandler("onClientMouseEnter", getRootElement(), onClientMouseHoverSetAlpha) 

Remember that you will also have to make it so it sets the Alpha back to the default when the mouse is not hovering over any of the specified elements.

Link to comment
  • Moderators

I was already writing this,,,, so I post it any way.

  
local guiTable = { 
   ["lobby"]= guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "images/lobbyBG.png", true),    
   ["arenas"]= guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "images/arenas.png", true),   
   ["dm"]= guiCreateStaticImage(0.157, 0.19, 0.17, 0.305, "images/areny/dm.png", true, arenas),  
   ["dd"]= guiCreateStaticImage(0.331, 0.19, 0.17, 0.305, "images/areny/dm.png", true, arenas) 
}  
  
        
        guiSetAlpha ( guiTable["dm"], 0.75 ) 
        guiSetAlpha ( guiTable["dd"], 0.75 ) 
  
addEventHandler( "onClientMouseEnter", root,  
    function(aX, aY) 
        for key,gui in pairs (guiTable) do 
              if gui == source then 
                  guiSetAlpha ( source, 1 ) 
                  return 
              end 
        end 
    end 
) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...