Jump to content

[HELP] Whats wrong?


AlvarO

Recommended Posts

I'm making that when a player clicks, interpolate moves again, but it makes the animation of the start, help please.

  
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() 
    now = getTickCount() 
    ax, ay = interpolateBetween(x*0.06, y*0.4,0,x*0.06, y*0.47,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    ax2, ay2 = interpolateBetween(x*0.37, y*0.4,0,x*0.37, y*0.47,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    ax3, ay3 = interpolateBetween(x*0.37, y*0.4,0,x*0.37, y*0.57,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    ax4, ay4 = interpolateBetween(x*0.52, y*0.4,0,x*0.52, y*0.47,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    ax5, ay5 = interpolateBetween(x*0.6, y*0.4,0,x*0.6, y*0.47,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    ax6, ay6 = interpolateBetween(x*(-0.18),y*0.2,0,x*(-0.18),y*0.24,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    ax7, ay7 = interpolateBetween(x*0.36,y*0.4,0,x*0.36,y*0.44,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    ax8, ay8 = interpolateBetween(x*0.91, y*0.2, 0, x*0.91, y*0.24, 0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    ax9, ay9 = interpolateBetween(x*0.38, y*0.465, 0, x*0.38, y*0.475, 0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    ax10, ay10 = interpolateBetween(x*0.532, y*0.465, 0, x*0.532, y*0.475, 0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    dxDrawImage(0, 0, x, y, "img/background.png") 
    dxDrawImage(ax9, ay9, 60, 60, "img/login.png") 
    dxDrawImage(ax10, ay10, 60, 60, "img/register.png") 
    dxDrawRectangle(ax, ay, x*0.2867, y*0.07, cambiarCoolor1, false) 
    dxDrawRectangle(ax2, ay2,x*0.05, y*0.07, cambiarCoolor1, false) 
    dxDrawRectangle(ax3, ay3,x*0.2, y*0.07, cambiarCoolor3, false) 
    dxDrawRectangle(ax4, ay4, x*0.05, y*0.07, cambiarCoolor2, false) 
    dxDrawRectangle(ax5, ay5, x*0.2867, y*0.07, cambiarCoolor2, false) 
    dxDrawText("SIGN IN", ax6, ay6, x/2-300/2+160+140, y*0.73+40, tocolor(255, 255, 255, 255), 0.5, font, "center", "center", false, false, true, true, false) 
    dxDrawText("PLAY AS GUEST", ax7, ay7, x/2-300/2+160+140, y*0.73+40, tocolor(255, 255, 255, 255), 0.5, font, "center", "center", false, false, true, true, false) 
    dxDrawText("ADD NEW ACCOUNT", ax8, ay8, x/2-300/2+160+140, y*0.73+40, tocolor(255, 255, 255, 255), 0.5, font, "center", "center", false, false, true, true, false) 
    showChat(false) 
    showCursor(true) 
end 
addEventHandler("onPlayerJoin", root, drawingLogin) 
addEventHandler("onClientRender", root, drawingLogin) 
  
--Botones 
function guestPlayer (button, state, absoluteX, absoluteY, wx, wy, wz, clickedElement) 
    if state == "down" then 
        if isCursorHover (x*0.37, y*0.57,x*0.2, y*0.07) then 
            removeEventHandler("onClientRender", getRootElement(), drawingLogin) 
            showChat(true) 
            showCursor(false) 
        end 
    end 
end 
addEventHandler ("onClientClick", getRootElement(), guestPlayer) 
  
function hideLogin (button, state, absoluteX, absoluteY, wx, wy, wz, clickedElement) 
    if state == "down" then 
        if isCursorHover (x*0.06, y*0.47, x*0.2867, y*0.07) then 
            start = getTickCount() 
            ax, ay = interpolateBetween(x*0.06, y*0.47,0,x*0.06, y*0.9, 0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
            ax2, ay2 = interpolateBetween(x*0.37, y*0.4,0,x*0.37, y*0.9,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
            ax3, ay3 = interpolateBetween(x*0.37, y*0.4,0,x*0.37, y*0.9,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
            ax4, ay4 = interpolateBetween(x*0.52, y*0.4,0,x*0.52, y*0.9,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
            ax5, ay5 = interpolateBetween(x*0.6, y*0.4,0,x*0.6, y*0.9,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
            ax6, ay6 = interpolateBetween(x*(-0.18),y*0.2,0,x*(-0.18),y*0.9,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
            ax7, ay7 = interpolateBetween(x*0.36,y*0.4,0,x*0.36,y*0.9,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
            ax8, ay8 = interpolateBetween(x*0.91, y*0.2, 0, x*0.91, y*0.9, 0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
            ax9, ay9 = interpolateBetween(x*0.38, y*0.465, 0, x*0.38, y*0.9, 0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
            ax10, ay10 = interpolateBetween(x*0.532, y*0.465, 0, x*0.532, y*0.9, 0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
        end 
    end 
end 
addEventHandler("onClientRender", root, hideLogin) 
addEventHandler ("onClientClick", getRootElement(), hideLogin) 
  
--Cambiar colores 
function cambiarColor() 
    if isCursorHover(x*0.06, y*0.47, x*0.2867, y*0.07) then 
            cambiarCoolor1 = tocolor(255, 255, 255, 125) 
        else 
            cambiarCoolor1 = tocolor(255, 255, 255, 75) 
    end 
end 
addEventHandler("onClientRender", root, cambiarColor) 
  
function cambiarColor1() 
    if isCursorHover(x*0.6, y*0.47, x*0.2867, y*0.07) then 
            cambiarCoolor2 = tocolor(255, 255, 255, 125) 
        else 
            cambiarCoolor2 = tocolor(255, 255, 255, 75) 
    end 
end 
addEventHandler("onClientRender", root, cambiarColor1) 
  
function cambiarColor2() 
    if isCursorHover(x*0.37, y*0.57,x*0.2, y*0.07) then 
            cambiarCoolor3 = tocolor(255, 255, 255, 125) 
        else 
            cambiarCoolor3 = tocolor(255, 255, 255, 75) 
    end 
end 
addEventHandler("onClientRender", root, cambiarColor2) 
  
function isCursorHover (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

testing :#

  
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() 
    ax, ay = interpolateBetween(x*0.06, y*0.4,0,x*0.06, y*0.47,0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
    dxDrawImage(0, 0, x, y, "img/background.png") 
    dxDrawImage(ax+0.32, ay+0.075, 60, 60, "img/login.png") 
    dxDrawImage(ax-0.068, ay+0.75, 60, 60, "img/register.png") 
    dxDrawRectangle(ax, ay, x*0.2867, y*0.07, cambiarCoolor1, false) 
    dxDrawRectangle(ax+0.31, ay,x*0.05, y*0.07, cambiarCoolor1, false) 
    dxDrawRectangle(ax+0.31, ay+0.10,x*0.2, y*0.07, cambiarCoolor3, false) 
    dxDrawRectangle(ax+0.46, ay, x*0.05, y*0.07, cambiarCoolor2, false) 
    dxDrawRectangle(ax, ay, x*0.2867, y*0.07, cambiarCoolor2, false) 
    dxDrawText("SIGN IN", ax-0.55, ay-0.23, x/2-300/2+160+140, y*0.73+40, tocolor(255, 255, 255, 255), 0.5, font, "center", "center", false, false, true, true, false) 
    dxDrawText("PLAY AS GUEST", ax+0.30, ay-0.3, x/2-300/2+160+140, y*0.73+40, tocolor(255, 255, 255, 255), 0.5, font, "center", "center", false, false, true, true, false) 
    dxDrawText("ADD NEW ACCOUNT", ax+0.85, ay-0.23, x/2-300/2+160+140, y*0.73+40, tocolor(255, 255, 255, 255), 0.5, font, "center", "center", false, false, true, true, false) 
    showChat(false) 
    showCursor(true) 
end 
addEventHandler("onPlayerJoin", root, drawingLogin) 
addEventHandler("onClientRender", root, drawingLogin) 
  
--Botones 
function guestPlayer (button, state, absoluteX, absoluteY, wx, wy, wz, clickedElement) 
    if state == "down" then 
        if isCursorHover (x*0.37, y*0.57,x*0.2, y*0.07) then 
            removeEventHandler("onClientRender", getRootElement(), drawingLogin) 
            showChat(true) 
            showCursor(false) 
        end 
    end 
end 
addEventHandler ("onClientClick", getRootElement(), guestPlayer) 
  
function hideLogin (button, state, absoluteX, absoluteY, wx, wy, wz, clickedElement) 
    if state == "down" then 
        if isCursorHover (x*0.06, y*0.47, x*0.2867, y*0.07) then 
            local now = getTickCount() 
            start = getTickCount() 
            ax, ay = interpolateBetween(x*0.06, y*0.47,0,x*0.06, y*0.9, 0, (now - start) / (( start + 400 ) - start ) , "InOutBounce" ) 
        end 
    end 
end 
addEventHandler("onClientRender", root, hideLogin) 
addEventHandler ("onClientClick", getRootElement(), hideLogin) 
  
--Cambiar colores 
function cambiarColor() 
    if isCursorHover(x*0.06, y*0.47, x*0.2867, y*0.07) then 
            cambiarCoolor1 = tocolor(255, 255, 255, 125) 
        else 
            cambiarCoolor1 = tocolor(255, 255, 255, 75) 
    end 
end 
addEventHandler("onClientRender", root, cambiarColor) 
  
function cambiarColor1() 
    if isCursorHover(x*0.6, y*0.47, x*0.2867, y*0.07) then 
            cambiarCoolor2 = tocolor(255, 255, 255, 125) 
        else 
            cambiarCoolor2 = tocolor(255, 255, 255, 75) 
    end 
end 
addEventHandler("onClientRender", root, cambiarColor1) 
  
function cambiarColor2() 
    if isCursorHover(x*0.37, y*0.57,x*0.2, y*0.07) then 
            cambiarCoolor3 = tocolor(255, 255, 255, 125) 
        else 
            cambiarCoolor3 = tocolor(255, 255, 255, 75) 
    end 
end 
addEventHandler("onClientRender", root, cambiarColor2) 
  
function isCursorHover (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

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