Jump to content

FADE DX


Recommended Posts

alguém me fala onde estou errando?, o código funciona para abrir o painel dx lentamente ( efeito de fade )

mais pra fechar não funciona, ele fecha direto e quando vou abrir dnv ja abre com o alpha no maximo, me ajudem :c

local screenH, screenW = guiGetScreenSize()
local x, y = (screenH/1366), (screenW/768)
mostrar = false
local alpha = 0
--------------------------------------------
function pdx()
  if mostrar == true then
  dxDrawRectangle(x * 300, y*221, x*323, y*248, tocolor(0, 0, 0, alpha), false)
  if alpha < 230 then 
  alpha = alpha + 4 else
  alpha >= 230 then
  alpha = alpha - 4
end
end
end
addEventHandler("onClientRender", root, pdx)

function abrirdx()
  if mostrar == false then
    showCursor(true)
    mostrar = true
    addEventHandler("onClientRender", root,pdx) else
      showCursor(false)
      mostrar = false
      removeEventHandler("onClientRender", root, pdx)
    end
end
bindKey("x", "down", abrirdx)

 

Link to comment
local screenH, screenW = guiGetScreenSize()
local x,y = (screenH/1366),(screenW/768)

local effect = {
	alpha = 0,
	tick = getTickCount(),
	state = false
}

function pdx()
	local progress = math.min((getTickCount()-effect.tick)/3000,1)
	if effect.state then
		effect.alpha = interpolateBetween(effect.alpha,0,0,1,0,0,progress,"Linear")
	else
		effect.alpha = interpolateBetween(effect.alpha,0,0,0,0,0,progress,"Linear")
		if progress >= 0.9 then
			removeEventHandler("onClientRender",root,pdx)
		end
	end
	dxDrawRectangle(x*300,y*221,x*323,y*248,tocolor(0,0,0,255*effect.alpha))
end

function abrirdx()
	effect.state = not effect.state
	effect.tick = getTickCount()
	showCursor(effect.state)
	if effect.state then
		removeEventHandler("onClientRender",root,pdx)
		addEventHandler("onClientRender",root,pdx)
    end
end
bindKey("x","down",abrirdx)

não testei

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...