Kilfwan Posted October 21, 2015 Posted October 21, 2015 Hola, tengo un pequeño error con ese evento.. Estaba creando un dxBoton para un login pero me di cuenta que si paso por un boton y bajo el cursor al otro se queda el otro aun con el color rojo pero si bajo mas se quitan los dos colores y asi pero el problema es solo si bajo el cursor en eje de las Y, pero no en de las X, no se si me explique bien este es el codigo: function movelogin ( _, _, xh, yh ) if (xh >= ( 261 / sx ) * x and xh < ( 261 / sx ) * x + ( 298 / sx ) * x ) and (yh >= ( 271 / sy ) * y and yh < ( 271 / sy ) * y + ( 285 / sy ) * y) then tr,tg,tb,ta = 153, 9, 16, 243 else tr,tg,tb,ta = 0, 0, 0, 243 end end addEventHandler( "onClientCursorMove", getRootElement( ), movelogin) Cual es el error
Tomas Posted October 21, 2015 Posted October 21, 2015 No entendí una mierda. Podrías crear una simple función que haga la aritmética ya la comparación lógica para evitar esa chorretera de caracteres.
Kilfwan Posted October 21, 2015 Author Posted October 21, 2015 No entendí una mierda. Podrías crear una simple función que haga la aritmética ya la comparación lógica para evitar esa chorretera de caracteres. A esto es lo que me refiero: http://imgur.com/4jNHlat Solo cuando bajo el cursor se queda asi, bajandolo un poco mas abajo se quita el color del primer boton. PD: Funciona igual con isCursorOnElement .
DeathMta Posted October 21, 2015 Posted October 21, 2015 function createMarwinButton(x, y, widht, height, text, bool, parent, info) button = guiCreateStaticImage(x, y, widht, height, "images/button_standard.png", bool, parent or nil) table.insert(marwinButtons, button) guiBringToFront(button) label = guiCreateLabel(0, 0, 1, 1, text, bool, button) guiBringToFront(label) setElementData(label, "parent", button) setElementData(button, "info", info) guiSetFont(label, font[1]) guiLabelSetColor ( label,21,82,67) guiLabelSetVerticalAlign(label, "center") guiLabelSetHorizontalAlign(label, "center") addEventHandler("onClientMouseEnter", label, markButton, false) addEventHandler("onClientMouseLeave", label, unmarkButton, false) return label end function markButton() parent = getElementData(source, "parent") guiStaticImageLoadImage(parent, "images/button_mouse.png") setElementData(getLocalPlayer(), "clickedButton", parent) playSound("sounds/button.mp3") end function unmarkButton(b, s) parent = getElementData(source, "parent") guiStaticImageLoadImage(parent, "images/button_standard.png") setElementData(getLocalPlayer(), "clickedButton", false) end guiate de eso lo saque de un login
alex17 Posted October 21, 2015 Posted October 21, 2015 No entendí una mierda. Podrías crear una simple función que haga la aritmética ya la comparación lógica para evitar esa chorretera de caracteres. A esto es lo que me refiero: http://imgur.com/4jNHlat Solo cuando bajo el cursor se queda asi, bajandolo un poco mas abajo se quita el color del primer boton. PD: Funciona igual con isCursorOnElement . postea la parte de los dx que forman el boton para poder ayudarte mejor
Tomas Posted October 21, 2015 Posted October 21, 2015 El problema es que estás comparando relativos con absolutos, si vas a utilizar relativos utiliza los primeros dos argumentos, si de lo contrario quieres usar absolutos, utiliza el tercer y cuarto argumento.
Enargy, Posted October 21, 2015 Posted October 21, 2015 Tomas se refiere a esto function isCursorOnElement(x,y,w,h) local mx,my = getCursorPosition () local fullx,fully = guiGetScreenSize() cursorx,cursory = mx*fullx,my*fully if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then return true else return false end end function movelogin ( _, _, xh, yh ) local x, y, w, h = xh, yh, --[[width]], --[[height]] if isCursorOnElement( xh, yh, w, h ) then tr,tg,tb,ta = 153, 9, 16, 243 else tr,tg,tb,ta = 0, 0, 0, 243 end end addEventHandler( "onClientCursorMove", getRootElement( ), movelogin)
Kilfwan Posted October 21, 2015 Author Posted October 21, 2015 Tomas se refiere a esto function isCursorOnElement(x,y,w,h) local mx,my = getCursorPosition () local fullx,fully = guiGetScreenSize() cursorx,cursory = mx*fullx,my*fully if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then return true else return false end end function movelogin ( _, _, xh, yh ) local x, y, w, h = xh, yh, --[[width]], --[[height]] if isCursorOnElement( xh, yh, w, h ) then tr,tg,tb,ta = 153, 9, 16, 243 else tr,tg,tb,ta = 0, 0, 0, 243 end end addEventHandler( "onClientCursorMove", getRootElement( ), movelogin) Gracias de igual manera, Aunque después me dí cuenta que era un error de argumentos.
Recommended Posts