AlvarO Posted October 5, 2015 Share Posted October 5, 2015 Hey guys, im triying to make something like, a window (dx) that when the resource starts makes an animation from up to down, and when a player click in a button inside of it, it will animate to down, there is my code: local x, y = guiGetScreenSize() local px, py = 1920, 1080 local sx, sy = (x/py), (y/py) local start = getTickCount() local font = dxCreateFont("font.ttf", 52, false) function drawingLogin() local now = getTickCount() local elapsedTime = now - start local endTime = start + 1000 local duration = endTime - start local progress = elapsedTime / duration local x1, y1 = interpolateBetween(x/2-200, y/7, 0, x/2-200, y/3.5, 0, progress, "OutBounce") local x2, y2 = interpolateBetween(x/2+93, y/2-65, 0, x/2+93, y/2-33, 0, progress, "OutBounce") dxDrawImage(0, 0, x, y, "img/background.png") dxDrawRectangle(x1-450, y1+200, 400, 50, rectanglecchanger2) dxDrawRectangle(x1+400, y1+200, 400, 50, tocolor(255, 255, 255, 75)) dxDrawRectangle(x1, y1+200, 65, 50, tocolor(255, 255, 255, 75)) dxDrawRectangle(x1+285, y1+200, 65, 50, tocolor(255, 255, 255, 75)) dxDrawRectangle(x1, y1+275, 350, 50, rectanglecchanger1) dxDrawImage(x2, y2, 50, 50, "img/login.png") dxDrawImage(x2-285, y2, 50, 50, "img/register.png") dxDrawText("SIGN IN", x1-310, y1-320, x, y, tocolor(255, 255, 255, 255), 0.4, font, "left", "center", false, false, false, true, true) dxDrawText("ADD NEW ACCOUNT", x1+475, y1-320, x, y, tocolor(255, 255, 255, 255), 0.4, font, "left", "center", false, false, false, true, true) dxDrawText("PLAY AS GUEST", x1+107, y1-175, x, y, tocolor(255, 255, 255, 255), 0.3, font, "left", "center", false, false, false, true, true) showChat(false) showCursor(true) end addEventHandler("onClientRender", root, drawingLogin) function playAsGuest (button, state, absoluteX, absoluteY, wx, wy, wz, clickedElement) if state == "down" then if isMouseInPosition (x/2-200, y/2+43, 350, 50) then removeEventHandler("onClientRender", getRootElement(), drawingLogin) showChat(true) showCursor(false) end end end addEventHandler ("onClientClick", getRootElement(), playAsGuest) function changeToLogin (button, state, absoluteX, absoluteY, wx, wy, wz, clickedElement) local now = getTickCount() local elapsedTime = now - start local endTime = start + 1000 local duration = endTime - start local progress = elapsedTime / duration local x1, y1 = interpolateBetween(x/2-200, y/7, 0, x/2-200, y/3.5, 0, progress, "OutBounce") if state == "down" then if isMouseInPosition (x/2-650, y/2-31, 400, 50) then x1, y1 = interpolateBetween(x/2-200, y/3.5, 0, x/2-200, y/6, 0, progress, "OutBounce") end end end addEventHandler ("onClientClick", getRootElement(), changeToLogin) addEventHandler("onClientRender", root, drawingLogin) function cambiarColor1() if isMouseInPosition(x/2-200, y/2+43, 350, 50) then rectanglecchanger1 = tocolor(255, 255, 255, 50) else rectanglecchanger1 = tocolor(255, 255, 255, 125) end end addEventHandler("onClientRender", root, cambiarColor1) function cambiarColor2() if isMouseInPosition(x/2-650, y/2-31, 400, 50) then rectanglecchanger2 = tocolor(255, 255, 255, 50) else rectanglecchanger2 = tocolor(255, 255, 255, 125) end end addEventHandler("onClientRender", root, cambiarColor2) function isMouseInPosition (x, y, width, height) if (not isCursorShowing ()) then return false end local sx, sy = guiGetScreenSize () local cx, cy = getCursorPosition () local cx, cy = (cx * sx), (cy*sy) if (cx >= x and cx <= x + width) and (cy >= y and cy <= y + height) then return true else return false end end Link to comment
KariiiM Posted October 5, 2015 Share Posted October 5, 2015 and? what's wrong with it , where is the error..etc more info Link to comment
AlvarO Posted October 5, 2015 Author Share Posted October 5, 2015 There's no error, as you can see I ask for help, for tell me how to make that when I click in the button "Sign In" all the dx elements move to down. Thanks. Link to comment
LoOs Posted October 6, 2015 Share Posted October 6, 2015 There's no error, as you can see I ask for help, for tell me how to make that when I click in the button "Sign In" all the dx elements move to down. Thanks. You may use another painting or change the local interpolateBetween and put the entire file , and then you change the name of x1 , y1, z1 in case you want to get off panel example :# start = getTickCount() function loading () local now = getTickCount() with = interpolateBetween(0,0,0,532,0,0, (now - start) / (( start + 10000 ) - start ) , "Linear" ) dxDrawRectangle(142, 222, 532, 41, tocolor(0, 0, 0, 255), false) dxDrawRectangle(142, 222, with, 41, tocolor(55, 215, 0, 255), false) end end addEventHandler("onClientRender",root,lodaing) bindKey("c","down",function () local now = getTickCount() start = getTickCount() with = interpolateBetween(with,0,0,0,0,0, (now - start) / (( start + 3000 ) - start ) , "Linear" ) end) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now