Jump to content

[HELP] How to create alpha animation for image?


Tokio

Recommended Posts

  • Moderators
function render ()
	local timeNow = getTickCount()
	local alpha = (timeNow % 510)
	if alpha > 255 then
		alpha = 255 - (alpha - 255)
	end
	local color = tocolor(255,255,255, alpha)
end

 

Each 1 alpha unit of 255 = 1 millisecond. Very easy example.

Which counts from: 0 > 255 > 0 > 255 > 0 etc.

 


If you want some custom timing: (2s = full animation ON/OFF)

 

local duration = 2000

local alpha = (timeNow % duration / duration) * 510

 

Edited by IIYAMA
  • Thanks 1
Link to comment
9 minutes ago, IIYAMA said:

function render ()
	local timeNow = getTickCount()
	local alpha = (timeNow % 510)
	if alpha > 255 then
		alpha = 255 - (alpha - 255)
	end
	local color = tocolor(255,255,255, alpha)
end

 

Each 1 alpha unit of 255 = 1 millisecond. Very easy example.

Which counts from: 0 > 255 > 0 > 255 > 0 etc.

How to slow down? O.o 

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