Jump to content

adding a fade in/out animation on dxdrawtext


Recommended Posts

function dxDrawBorderedText (outlinetextlefttoprightbottomcolorscalefontalignXalignYclipwordBreakpostGUIcolorCodedsubPixelPositioningfRotationfRotationCenterXfRotationCenterY)
    local outline = (scale or 1) * (1.333333333333334 * (outline or 1))
    dxDrawText (text:gsub("#%x%x%x%x%x%x"""), left - outline, top, right - outline, bottom, tocolor (000225), scale, font, alignX, alignY, clip, wordBreak, postGUI, false, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
    dxDrawText (text:gsub("#%x%x%x%x%x%x"""), left + outline, top, right + outline, bottom, tocolor (000225), scale, font, alignX, alignY, clip, wordBreak, postGUI, false, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
    dxDrawText (text:gsub("#%x%x%x%x%x%x"""), left, top - outline, right, bottom - outline, tocolor (000225), scale, font, alignX, alignY, clip, wordBreak, postGUI, false, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
    dxDrawText (text:gsub("#%x%x%x%x%x%x"""), left, top + outline, right, bottom + outline, tocolor (000225), scale, font, alignX, alignY, clip, wordBreak, postGUI, false, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
    dxDrawText (text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
end
 
function fadedText()
    dxDrawBorderedText(2.5"Lorem ipsum dolor sit amet"00, screenX, screenY - (screenY * 0.9), tocolor(176,192,222,255), 2,  "pricedown""center""center"truetruetruetruetrue)
    dxDrawBorderedText(2.5"Lorem ipsum dolor sit amet."00, screenX, screenY - (screenY * 0.84), tocolor(135,206,250,255), 1,  Roboto, "center""center"truetruetruetruetrue)
 
     setTimer(function()
         removeEventHandler("onClientRender", root, fadedText)
    end30001)    
end
 
function fadedHittheElementmatchingDimension )
    if ( theElement == localPlayer ) then 
       addEventHandler("onClientRender", root, fadedText)
    end
end
addEventHandler("onClientColShapeHit", groveCol, fadedHit)
 
// im trying to fade this script but i cant can someone help me pls
Link to comment

hi you can use textlib for this kind of stuff I use it too it works

example

local screenW, screenH = guiGetScreenSize()
test = dxText:create("Test", screenW/2, screenH/2, false)
test:font("default-bold")
test:scale(4.0) 
test:color(255,255,255,255)
test:visible(false)

addCommandHandler("fade",
function()
test:visible(true)
Animation.createAndPlay(test, dxTextFadeIn(3000))
end
)

 

Link to comment

You probably need something like this:

function drawStuff( alpha )
  local alpha = alpha or 255
  local color = tocolor( 255, 255, 255, alpha )
  -- draw something
end

local gAlpha = 0

function fadeExample( ) -- goes from 0 to 255
  drawStuff( gAlpha)
  gAlpha = gAlpha + 0.05
  if gAlpha == 255 then
    removeEventHandler( "onClientRender", root, fadeExample )
  end
end
addEventHandler( "onClientRender", root, fadeExample )

 

Edited by JeViCo
snippet to code formatting
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...