shike1000 Posted February 18, 2017 Posted February 18, 2017 (edited) Buenas, estoy creando una barra vida para los vehiculos pero despues de conseguir que me funcione me he dado cuenta de que se des centra en otras resoluciones y no comprendo el porque, si alguien me pudiera decir donde me equivoque y el porque os lo agradeceria user_x, user_y = guiGetScreenSize () local_x, local_y = 1366, 768 function drawVehicleHUD() local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) if ( vehicle ) then if ( getElementHealth( vehicle ) >= 1000 ) then vehiclehealth = 100 else vehiclehealth = math.floor(getElementHealth ( vehicle )/10) end dxDrawRectangle((38.5/local_x)*user_x, (675/local_y)*user_y, (173/local_x)*user_x, (12/local_y)*user_y, tocolor(51,51,51,100), true) dxDrawRectangle((38.5/local_x)*user_x, (675/local_y)*user_y, (173/local_x)*user_x/100*vehiclehealth,(12/local_y)*user_y, tocolor(0,183,255,100), true) end end addEventHandler("onClientRender", root, drawVehicleHUD) Edited February 18, 2017 by shike1000 No estaba completo
eloriginal Posted February 19, 2017 Posted February 19, 2017 local sx, sy = guiGetScreenSize() local sourceX, sourceY = 1336, 768 dxDrawRectangle( sx*(200/sourceX), sy*(120/sourceY), sx*(200/sourceX), sy*(100/sourceY), tocolor(255, 0, 0) )
shike1000 Posted February 20, 2017 Author Posted February 20, 2017 @eloriginal Le sigue ocurriendo lo mismo, se va más a la izquierda en otras resoluciones.
eloriginal Posted February 20, 2017 Posted February 20, 2017 @shike1000 ve cambiadoles lo numero de el argumento ( sx*(200/sourceX), sy*(120/sourceY), sx*(200/sourceX), sy*(100/sourceY), tocolor(255, 0, 0) ) hasta el gusto tuyo+
shike1000 Posted February 20, 2017 Author Posted February 20, 2017 Just now, eloriginal said: @shike1000 ve cambiadoles lo numero de el argumento ( sx*(200/sourceX), sy*(120/sourceY), sx*(200/sourceX), sy*(100/sourceY), tocolor(255, 0, 0) ) hasta el gusto tuyo+ Fue exactamente lo que hice, @eloriginal.
#Dv^ Posted February 20, 2017 Posted February 20, 2017 (edited) 1 hour ago, eloriginal said: @shike1000 ve cambiadoles lo numero de el argumento ( sx*(200/sourceX), sy*(120/sourceY), sx*(200/sourceX), sy*(100/sourceY), tocolor(255, 0, 0) ) hasta el gusto tuyo+ Cambiar los número no servirá de nada @eloriginal, ahí sólo estás adaptando el código a tu resolución. @shike1000 sólo quiere que la imagen se adapte en las demás resoluciones para que no se vea desorientado Usá este código: local screenW,screenH = guiGetScreenSize() local resW, resH = 1366, 768 local x, y = (screenW/resW), (screenH/resH) Edited February 20, 2017 by #Dv^
shike1000 Posted February 20, 2017 Author Posted February 20, 2017 4 minutes ago, #Dv^ said: Cambiar los número no servirá de nada, ahí sólo estás adaptando el código a tu resolución. Él quiere que la imagen se adapte en las demás resoluciones para que no se vea desorientado Usá este código: local screenW,screenH = guiGetScreenSize() local resW, resH = 1366, 768 local x, y = (screenW/resW), (screenH/resH) ¿No es lo mismo que lo que yo hice pero con mas variables? Disculpa mi ignorancia
#Dv^ Posted February 20, 2017 Posted February 20, 2017 local screenW,screenH = guiGetScreenSize() local resW, resH = 1366, 768 local x, y = (screenW/resW), (screenH/resH) function drawVehicleHUD() local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) if ( vehicle ) then vehiclehealth = getElementHealth(vehicle) if vehiclehealth > 244 then dxDrawRectangle(x*83, y*725, x*200, y*20, tocolor(51,51,51,100), true) dxDrawRectangle(x*83, y*725, vehiclehealth/297 * 80 - 70, y*20, tocolor(0,183,255,100), true) end end end addEventHandler("onClientRender", root, drawVehicleHUD)
shike1000 Posted February 20, 2017 Author Posted February 20, 2017 46 minutes ago, #Dv^ said: local screenW,screenH = guiGetScreenSize() local resW, resH = 1366, 768 local x, y = (screenW/resW), (screenH/resH) function drawVehicleHUD() local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) if ( vehicle ) then vehiclehealth = getElementHealth(vehicle) if vehiclehealth > 244 then dxDrawRectangle(x*83, y*725, x*200, y*20, tocolor(51,51,51,100), true) dxDrawRectangle(x*83, y*725, vehiclehealth/297 * 80 - 70, y*20, tocolor(0,183,255,100), true) end end end addEventHandler("onClientRender", root, drawVehicleHUD) Nada, se sigue desviando a la izquierda cuando cambio de resolucion
Recommended Posts