Jump to content

How to fade out to a 2nd Image


Overkillz

Recommended Posts

Hey everyone, Im here again.

I hope u can help me with this little help.

I will like to make a fade out the first image to the second image.

Part of the code:

local sWidth,sHeight = guiGetScreenSize()  
    local Width,Height = 395,910 
    local X = (sWidth/2) - (Width/2) 
    local Y = (sHeight/2) - (Height/2) 
     
    Image = guiCreateStaticImage( 0, 0, 1920, 1200, "img/login_bg.png", false ) 
    Image2 = guiCreateStaticImage( 0, 0, 1920, 1200, "img/login_bgfinal.png", false ) 
    guiSetEnabled (Image, false) 
    guiSetEnabled (Image2, false) 

Please, I need this, Im trying to develeop a thing.

Thanks for ur time, regards. ;)

Link to comment

You should use the dxDrawImage function.

You can try using this code, but I didn't test it:

local sWidth,sHeight = guiGetScreenSize() 
local Width,Height = 395,910 
local X = (sWidth/2) - (Width/2) 
local Y = (sHeight/2) - (Height/2) 
local alpha = 255 
local mode = "fade" 
local img = "img/login_bg.png" 
  
  
addEventHandler ( "onClientRender", root, function ( ) 
    if ( mode == "fade" ) then 
        if ( alpha <= 10 ) then 
            img = "img/login_bgfinal.png" 
            mode = "build" 
        else 
            alpha = alpha - 2 
        end 
    else 
        alpha = alpha + 2 
        if ( alpha > 255 ) then 
            alpha = 255 
        end 
    end  
    dxDrawImage ( 0, 0, 1920, 1200, img, tocolor ( 255, 255, 255, alpha ) ) 
end ) 

Link to comment
  
local sWidth,sHeight = guiGetScreenSize() 
local Width,Height = 395,910 
local X = (sWidth/2) - (Width/2) 
local Y = (sHeight/2) - (Height/2) 
local alpha = 255 
local mode = "fade" 
local img = "img/login_bg.png" 
  
  
addEventHandler ( "onClientRender", root, function ( ) 
    if ( mode == "fade" ) then 
        if ( alpha <= 10 ) then 
            img = "img/login_bgfinal.png" 
            mode = "build" 
        else 
            alpha = alpha - 1 
        end 
    else 
        alpha = alpha + 1 
        if ( alpha > 255 ) then 
            alpha = 255 
        end 
    end 
    dxDrawImage ( 0, 0, 1920, 1200, img, tocolor ( 255, 255, 255, alpha ) ) 
end ) 
  

Link to comment
  
local sWidth,sHeight = guiGetScreenSize() 
local Width,Height = 395,910 
local X = (sWidth/2) - (Width/2) 
local Y = (sHeight/2) - (Height/2) 
local alpha = 255 
local mode = "fade" 
local img = "img/login_bg.png" 
  
  
addEventHandler ( "onClientRender", root, function ( ) 
    if ( mode == "fade" ) then 
        if ( alpha <= 10 ) then 
            img = "img/login_bgfinal.png" 
            mode = "build" 
        else 
            alpha = alpha - 1 
        end 
    else 
        alpha = alpha + 1 
        if ( alpha > 255 ) then 
            alpha = 255 
        end 
    end 
    dxDrawImage ( 0, 0, 1920, 1200, img, tocolor ( 255, 255, 255, alpha ) ) 
end ) 
  

Thanks for help me, but the problem still showing it, the difference, now its more faster xD

Link to comment
  
  
local sWidth,sHeight = guiGetScreenSize() 
local Width,Height = 395,910 
local X = (sWidth/2) - (Width/2) 
local Y = (sHeight/2) - (Height/2) 
local alpha = 255 
local mode = "fade" 
local img = "img/login_bg.png" 
  
  
addEventHandler ( "onClientRender", root, function ( ) 
    if ( mode == "fade" ) then 
        if ( alpha <= 10 ) then 
            img = "img/login_bgfinal.png" 
            mode = "build" 
        else 
            alpha = alpha - 5 
        end 
    else 
        alpha = alpha + 5 
        if ( alpha > 255 ) then 
            alpha = 255 
        end 
    end 
    dxDrawImage ( 0, 0, 1920, 1200, img, tocolor ( 255, 255, 255, alpha ) ) 
end ) 
  
  

Link to comment
  
  
local sWidth,sHeight = guiGetScreenSize() 
local Width,Height = 395,910 
local X = (sWidth/2) - (Width/2) 
local Y = (sHeight/2) - (Height/2) 
local alpha = 255 
local mode = "fade" 
local img = "img/login_bg.png" 
  
  
addEventHandler ( "onClientRender", root, function ( ) 
    if ( mode == "fade" ) then 
        if ( alpha <= 10 ) then 
            img = "img/login_bgfinal.png" 
            mode = "build" 
        else 
            alpha = alpha - 5 
        end 
    else 
        alpha = alpha + 5 
        if ( alpha > 255 ) then 
            alpha = 255 
        end 
    end 
    dxDrawImage ( 0, 0, 1920, 1200, img, tocolor ( 255, 255, 255, alpha ) ) 
end ) 
  
  

The same thing, just more slower and less returns

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