Jump to content

interpolateBetween Problem


Karuzo

Recommended Posts

Hey Guys,

It's me again. Idk what's going on with me but i have problems on the easiest things lol.

So this is my problem: I would like to interpolate the picture in and out, in works but out doesn't. It always dissappears right after the click(tho it shouldn't do that.)

My Code:

     
local x, y = guiGetScreenSize() 
local w,h = 400,600 
local px, py = x/2-w/2,y/1.5-h/1.5 
local data = {} 
--this is interpolating the rendertarget in. 
    local now = getTickCount() 
        local elapsedTime = now - data.openTick 
        local duration = data.endStarTime - data.openTick 
        local progress = elapsedTime / duration 
        intx,inty = interpolateBetween(px-150,y,0,px,py,0,progress,data.easingType) 
        dxDrawImage(intx, inty, w, h, data.renderTarget, 0, 0, 0, tocolor(255, 255, 255, 255), false) 
    end 
end 
  
function renderout() 
--and this is interpolating out 
    local now = getTickCount() 
    local elapsedTime = now - data.endTime 
    local duration = data.endTime - data.outTick 
    local progress = elapsedTime / duration 
    intx,inty = interpolateBetween(px,py,0,px-150,py-150,0,progress,data.easingType) 
    if now >= data.endTime  then 
        removeEventHandler("onClientRender", root, renderout) 
        removeEventHandler("onClientRender", root, render) 
        outputChatBox("out")--it outputs out but the picture/event handler was already removed. 
    end 
end 
  
  
bindKey(data.keyToOpen,data.keyState, 
    function() 
        data.open = not data.open 
        showCursor(data.open) 
        if data.open then 
            addEventHandler("onClientRender",root,render) 
            data.openTick = getTickCount() 
            data.endStarTime = data.openTick + 2000 
        else 
            data.outTick = getTickCount() 
            data.endTime = data.outTick + 2000 
            addEventHandler("onClientRender",root,renderout) 
        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...