Jump to content

dxDrawColorText Fade Help ^^


Overkillz

Recommended Posts

Hey everone, I hope u are ok, Always I must say this due to this community always help me :D

Well, about my question, I will like to know if is possible add a fade effet

-appear and dessapear

0,5 seconds to fade appear

1 seconds appear

0,5 seconds fade dissapear/out

local tagColor = rgbToHex(r,g,b) or "#FFFFFF" 
  
 dxDrawColorText("#ffffffWinner: "..tagColor..getPlayerName(winnerD).." #ffffff!", screenWidth/2, screenHeight/5.9, screenWidth/2, screenHeight/3.5, tocolor ( 255,255, 255, 180 ), 1.9, "default-bold","center" ) 
end 

This is part of code, I will like to get help with this, or get some suggestion to do it.

Thanks and regards. ^^

Link to comment
  • Moderators

did you ever worked with time? At school?

Your setup:

local timeStart = getTickCount() -- get the computer time of this moment 
  
local animationTime = 3000 -- 3 seconds -- This is how long your animation would take, 
--futureTime = timeNow + 3000 -- the time now + 3 seconds, this is when the animation part should stop 
  
  

Calculate the progress:(this is when you are drawing your text)

  
local timeNow = getTickCount() -- get the computer time of this moment 
  
local differences = timeNow - timeStart -- calculate the differences between the start time of the animation and the time now of this moment. 
  
local progress = differences/animationTime -- factor = multiplier 
  
--------------------------------------------------------------------------------------- 
--------------------------------------------------------------------------------------- 
--------------------------------------------------------------------------------------- 
  
-- invert the progress? -- 
--progress = 1-progress 
------------------------------ 
  
if  progress <= 0 then -- check if the animation hasn't ended yet. 
  
local yourTextPosition = progress*distance 
  
end  
  

It is some basic math, to calculate progress.

Or you can do it with a lot of timers, which I will not recommend.(and that isn't very smooth)

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