Jump to content

Help InterpolateBetween


Zinjaaa

Recommended Posts

As I can add this feature to my panel (InterpolateBetween)

Example

Press O OutBounce effect (Open)

Press O OutBounce effect (Close)

My client

local isPlayerViewingPanel = false 
local sw,sh = guiGetScreenSize() 
  
function dxDrawTheImage ( ) 
    if isPlayerViewingPanel then 
        dxDrawImage ( 240, 145, 550, 480, "window.png" ) 
        dxDrawText ( "Rules", sw/2 - 26, sh/2 - 230, sw/2 + 175, sh/2 + 80, tocolor ( 255, 255, 255, 255 ), 1.6, "default-bold") 
         
    end 
end 
  
addEventHandler ( "onClientRender", root, dxDrawTheImage ) 
  
bindKey("O", "down",function() 
    if ( isPlayerViewingPanel == true ) then           
        isPlayerViewingPanel = false 
        showCursor (false) 
    else               
        isPlayerViewingPanel = true 
        showCursor (true) 
    end 
end 
) 

I want Effect ''OutBounce"

You can create example without using wikipedia? I really do not know much about the example of wikipedia

I do not understand much this.

Greetings! att: Zinjaaa

Edited by Guest
Link to comment
function dxDrawAnimWindow(text,alto,ancho,color,font,anim) 
--dxDrawAnimWindow(tittle, height, width, color, font, anim( easing value ) 
    local x,y = guiGetScreenSize() 
  
    btAncho = ancho 
    btAlto = alto/20 
  
    local now = getTickCount() 
    local elapsedTime = now - start 
    local endTime = start + 1500 
    local duration = endTime - start 
    local progress = elapsedTime / duration 
    local x1, y1, z1 = interpolateBetween ( 0, 0, 0, ancho, alto, 255, progress, anim) 
    local x2, y2, z2 = interpolateBetween ( 0, 0, 0, btAncho, btAlto, btAlto/11, progress, anim) 
  
    posx = (x/2)-(x1/2) 
    posy = (y/2)-(y1/2) 
  
    dxDrawRectangle ( posx, posy-y2, x2, y2, color ) 
    dxDrawRectangle ( posx, posy, x1, y1, tocolor ( 0, 0, 0, 200 ) ) 
    dxDrawText ( text, 0, -(y1)-y2, x, y, tocolor ( 255, 255, 255, 255 ), z2, font,"center","center")    
    
--For more information of animation, visit the next page: [url=https://wiki.multitheftauto.com/wiki/Easing]https://wiki.multitheftauto.com/wiki/Easing[/url] 
  
end 

This function was made by @Bc# : viewtopic.php?f=146&t=61065

Link to comment
local isPlayerViewingPanel = false 
local sw,sh = guiGetScreenSize() 
  
function main ( ) 
    if isPlayerViewingPanel then 
        start = getTickCount() 
        addEventHandler ( "onClientRender", root, dxDrawTheImage )       
    end 
end 
  
  
function dxDrawTheImage() 
     
    x,y = guiGetScreenSize() 
  
    ancho=550 
    alto=480 
  
    local now = getTickCount() 
    local elapsedTime = now - start 
    local endTime = start + 1500 
    local duration = endTime - start 
    local progress = elapsedTime / duration 
    local x1, y1, z1 = interpolateBetween ( 0, 0, 0, ancho, alto, 255, progress, OutBounce) 
  
    posx = (x/2)-(x1/2) 
    posy = (y/2)-(y1/2) 
  
    dxDrawImage ( posx, posy-y2, x2, y2, "window.png" ) 
    dxDrawText ( "Rules", sw/2 - 26, sh/2 - 230, sw/2 + 175, sh/2 + 80, tocolor ( 255, 255, 255, 255 ), 1.6, "default-bold") 
end 
  
bindKey("O", "down",function() 
    if ( isPlayerViewingPanel == true ) then           
        isPlayerViewingPanel = false 
        showCursor (false) 
    else               
        isPlayerViewingPanel = true 
        showCursor (true) 
    end 
end 
) 

You'll have to do something how this, this is not tested, so you'll have to see if it has a bug.

Link to comment

You'll have to do something how this, this is not tested, so you'll have to see if it has a bug.

Try this:

local isPlayerViewingPanel = false 
local sw,sh = guiGetScreenSize() 
  
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
    start = getTickCount() 
end 
) 
  
function main ( ) 
    if isPlayerViewingPanel then 
        addEventHandler ( "onClientRender", root, dxDrawTheImage )  
    else 
        removeEventHandler("onClientRender", root, dxDrawTheImage) 
    end 
end 
  
  
function dxDrawTheImage() 
    
    x,y = guiGetScreenSize() 
  
    ancho=550 
    alto=480 
  
    local now = getTickCount() 
    local elapsedTime = now - start 
    local endTime = start + 1500 
    local duration = endTime - start 
    local progress = elapsedTime / duration 
    local x1, y1, z1 = interpolateBetween ( 0, 0, 0, ancho, alto, 255, progress, "OutBounce") 
  
    posx = (x/2)-(x1/2) 
    posy = (y/2)-(y1/2) 
  
    dxDrawImage ( posx, posy-y2, x2, y2, "window.png" ) 
    dxDrawText ( "Rules", sw/2 - 26, sh/2 - 230, sw/2 + 175, sh/2 + 80, tocolor ( 255, 255, 255, 255 ), 1.6, "default-bold") 
end 
  
bindKey("O", "down",function() 
    if ( isPlayerViewingPanel == true ) then           
        isPlayerViewingPanel = false 
        showCursor (false) 
        main() 
    else               
        isPlayerViewingPanel = true 
        showCursor (true) 
        main() 
    end 
end 
) 

Link to comment

I have fixed the script on my local server. (the Y in dxDrawImage might need a little adjusting)

local isPlayerViewingPanel = false 
local sw,sh = guiGetScreenSize() 
  
function main ( ) 
    if isPlayerViewingPanel then 
        start = getTickCount() 
        addEventHandler ( "onClientRender", root, dxDrawTheImage ) 
    else 
        removeEventHandler("onClientRender", root, dxDrawTheImage) 
    end 
end 
  
  
function dxDrawTheImage() 
    
    x,y = guiGetScreenSize() 
  
    ancho=550 
    alto=480 
  
    local now = getTickCount() 
    local elapsedTime = now - start 
    local endTime = start + 1500 
    local duration = endTime - start 
    local progress = elapsedTime / duration 
    local x1, y1, z1 = interpolateBetween ( 0, 0, 0, ancho, alto, 255, progress, "OutBounce") 
    local x2, y2, z2 = interpolateBetween ( 0, 0, 0, ancho, alto, alto/11, progress, 'OutBounce') 
  
    posx = (x/2)-(x1/2) 
    posy = (y/2)-(y1/2) 
  
    dxDrawImage ( posx, posy-y2/2, x2, y2, "window.png" ) 
    dxDrawText ( "Rules", sw/2 - 26, sh/2 - 230, sw/2 + 175, sh/2 + 80, tocolor ( 255, 255, 255, 255 ), 1.6, "default-bold") 
end 
  
bindKey("O", "down",function() 
    if ( isPlayerViewingPanel == true ) then           
        isPlayerViewingPanel = false 
        showCursor (false) 
        main() 
    else               
        isPlayerViewingPanel = true 
        showCursor (true) 
        main() 
    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...