Jump to content

Moving DX object


Recommended Posts

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

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

function pdx()
	local progress = math.min((getTickCount()-effect.tick)/3000,1)
	if effect.state then
		effect.alpha,effect.x = interpolateBetween(effect.alpha,effect.x,0,1,x*300,0,progress,"Linear")
	else
		effect.alpha,effect.x = interpolateBetween(effect.alpha,effect.x,0,0,0,0,progress,"Linear")
		if progress >= 0.9 then
			removeEventHandler("onClientRender",root,pdx)
		end
	end
	dxDrawRectangle(effect.x,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)

I didn't test

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