Jump to content

Using Static image and interpolate between


Recommended Posts

Posted

i am using an image, as a background for my login GUI and it covers the whole screen but it lags a tonne, i do not know why it lags so much, could it be the sizing or the quality of the image causing this lagging?

local x, y, _ = interpolateBetween ( x1, y1, 0, x2, y2, 0,  progress, "OutBounce" ) 
    ---dxDrawRectangle ( x, y, width, height, tocolor ( 0, 0, 0, 45 ) ) 
    dxDrawImage( x, y, width, height, "jjlogo.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
    ----guiCreateStaticImage( 0.0,0.0,1920.0,1080.0, "bg.png", true ) 
    ---dxDrawImage( 0.0, 0.0, width, height, "bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
function background() 
   guiCreateStaticImage( x, y, width, height, "bg.png", false ) 
   guiBringToFront(background) 
end 
addEventHandler ( "onClientRender", root, background ) 
end ) 

Note this is not full script just might i add with the image its kinda like, you know when you are lacking memory and you like drag what ever windows app around and it like lags, like 3d effect is this the image or is it the use of using a dx with gui?

i have used DX and plain simple GUI together and no errors

Posted

i tried dxDrawImage but lagg still occurs it seems to be just that image because i tried others and it has no FPS issues ever and i am using onClientRender could this cause it?

Posted

You have to use onClientRender event since dx drawings have to be rendered every frame otherwise you would only see them for one frame. So normally tha shouldn't cause laggs.

Please show us your current code

Posted
local sx, sy = guiGetScreenSize ( ) 
local width, height = 600, 500 
local point_start = { (sx/2-width/2), -height } 
local point_end = { (sx/2-width/2), (sy/2-height/2) } 
  
addEventHandler ( "onClientRender", root, function ( ) 
    if not startTime then 
        startTime = getTickCount ( ) 
    end if not endTime then 
        endTime = getTickCount ( ) + 3000 
    end 
    local now = getTickCount() 
    local elapsedTime = now - startTime 
    local duration = endTime - startTime 
    local progress = elapsedTime / duration 
    local setback = guiBringToFront () 
    
    x1, y1 = unpack ( point_start ) 
    x2, y2 = unpack ( point_end ) 
    
    local x, y, _ = interpolateBetween ( x1, y1, 0, x2, y2, 0,  progress, "OutBounce" ) 
    ---dxDrawRectangle ( x, y, width, height, tocolor ( 0, 0, 0, 45 ) ) 
    dxDrawImage(x, y, width, height, "jjlogo.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
    guiBringToFront(setback) 
    ---dxDrawImage(172, 70, 720, 538, "bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
    --dxDrawImage( x, y, width, height, "jjlogo.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
    ----guiCreateStaticImage( 0.0,0.0,1920.0,1080.0, "bg.png", true ) 
    ---dxDrawImage( 0.0, 0.0, width, height, "bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
--function background() 
   --dxDrawImage(0.0, 0.0, 1024, 768, "bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
  -- guiBringToFront(background) 
--end 
--addEventHandler ( "onClientRender", root, background ) 
end ) 
  
function background() 
   dxDrawImage(309, 142, 414, 325, "bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
end 
addEventHandler ( "onClientRender", root, background )--]] 
  
  
---[[addEventHandler("onClientResourceStart", resourceRoot, 
   -- function()     
  --  end 
--)---- 
  
--addEventHandler("onClientRender", root, 
   -- function() 
         
        --dxDrawImage(309, 142, 414, 325, "test.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
   -- end 
--) 

Very messy sorry about that its kinda my notes

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