Jump to content

x[مسآعدة ]x أنميشن غير منتهية interpolateBetween


coNolel

Recommended Posts

السلآم عليكم ورحمة الله تعالى وبركاته

اليوم ي عيال سويت كم شي بسيط دي إكس اجرب وش ف مخي

ولقيت صعوبة ف فنكشن interpolateBetween

لكن بحمد الله تغلبت عليها

والحين جت ع بالي فكرة اني اسوي بها انميشين لا منتهي 

يعني timeless

مثلا انا مسوي مستطيل كبير زي خلفية يوم يشتغل السكربت يجي alpha من 0 إلى 255

1لكن يوم يصير Progress يوقف الأنميشن

كيف أخليه يوم يوصل progress 1 يرجع ينقص إلى الصفر 

وبكذا ما يخلص الإفكت حقه او الأنميشين ابد ض1

الكود :

<lua>local timing = 0

function test()

        timing = timing + 0.02
        if timing >=1 then
        timing = timing - 0.02
        end
        
        backgroundAlpha = interpolateBetween ( 0, 0, 0, 255, 0, 0, timing, "Linear" )
                          
        
        dxDrawRectangle(0, 0, sX, sY, tocolor(255, 255, 255, backgroundAlpha), false) -- background

end

 

 

</lua>

 

وشكرا جزيلآ ، السلام خير ختام

ف أمان الله

Link to comment
local Timing = 0
addEventHandler ( "onClientRender", root,
	function ()
        Timing = Timing + 0.02
		backgroundAlpha = interpolateBetween ( 0, 0, 0, 255, 0, 0, Timing, "Linear" )
        if backgroundAlpha >= 255 then
			Timing = 0
        end
        dxDrawRectangle(0, 0, 800, 600, tocolor ( 255, 255, 255, backgroundAlpha ), false) 
	end
) 

 

  • Like 1
Link to comment

أظن انو فيه غلط ، يوم جربت حقك ي خلف طلع عندي يوم يجي 255 يعيد ، وانا أبيه يرجع عد تناقصي :)

19 minutes ago, خلف said:

local Timing = 0
addEventHandler ( "onClientRender", root,
	function ()
        Timing = Timing + 0.02
		backgroundAlpha = interpolateBetween ( 0, 0, 0, 255, 0, 0, Timing, "Linear" )
        if backgroundAlpha >= 255 then
			Timing = 0
        end
        dxDrawRectangle(0, 0, 800, 600, tocolor ( 255, 255, 255, backgroundAlpha ), false) 
	end
) 

 

 

Link to comment
Alpha = 0
setTimer ( function ( ) 
	if Alpha == 1 then 
		StartA = getTickCount ( )
		Alpha = 0 
	elseif Alpha == 0 then 
		StartA = getTickCount ( )
		Alpha = 1 
		end 
end, 3000, 0 )

addEventHandler ( "onClientRender", root,
	function ( )
        if Alpha == 0 then
			Hide ( )
		else
			Show ( )
		end
        dxDrawRectangle(0, 0, 800, 600, tocolor ( 255, 255, 255, backgroundAlpha ), false) 
	end
) 

function Hide ( )
	local now = getTickCount ( )
	local endTime = StartA - 3000
	local elapsedTime = now - StartA 
	local duration = endTime - StartA
	local progress = elapsedTime / duration
	backgroundAlpha = interpolateBetween ( 0, 0, 0, 255, 0, 0, progress, "Linear" )
	Alpha = 0
end

function Show ( )
	local now = getTickCount ( )
	local endTime = StartA + 3000
	local elapsedTime = now - StartA 
	local duration = endTime - StartA
	local progress = elapsedTime / duration
	backgroundAlpha = interpolateBetween ( 0, 0, 0, 255, 0, 0, progress, "Linear" )
	Alpha = backgroundAlpha + Alpha
	Alpha = 1
end

الكود شغال

لاكن بيجي خطاء بالديبوق

Edited by خلف
  • Like 1
Link to comment
34 minutes ago, خلف said:

Alpha = 0
setTimer ( function ( ) 
	if Alpha == 1 then 
		StartA = getTickCount ( )
		Alpha = 0 
	elseif Alpha == 0 then 
		StartA = getTickCount ( )
		Alpha = 1 
		end 
end, 3000, 0 )

addEventHandler ( "onClientRender", root,
	function ( )
        if Alpha == 0 then
			Hide ( )
		else
			Show ( )
		end
        dxDrawRectangle(0, 0, 800, 600, tocolor ( 255, 255, 255, backgroundAlpha ), false) 
	end
) 

function Hide ( )
	local now = getTickCount ( )
	local endTime = StartA - 3000
	local elapsedTime = now - StartA 
	local duration = endTime - StartA
	local progress = elapsedTime / duration
	backgroundAlpha = interpolateBetween ( 0, 0, 0, 255, 0, 0, progress, "Linear" )
	Alpha = 0
end

function Show ( )
	local now = getTickCount ( )
	local endTime = StartA + 3000
	local elapsedTime = now - StartA 
	local duration = endTime - StartA
	local progress = elapsedTime / duration
	backgroundAlpha = interpolateBetween ( 0, 0, 0, 255, 0, 0, progress, "Linear" )
	Alpha = backgroundAlpha + Alpha
	Alpha = 1
end

الكود شغال

لاكن بيجي خطاء بالديبوق

 
 
if not StartA then return end

^_^

  • Like 1
Link to comment

جرب كذا

local aState = false
	
local Timing = 0

addEventHandler ( "onClientRender", root,

	function (	)
	
	if ( aState == false ) then
		
	Timing = Timing + 0.02
		
	elseif ( aState == true ) then
		
	Timing = Timing - 0.02
		
	end
		
	backgroundAlpha = interpolateBetween ( 0, 0, 0, 255, 0, 0, Timing, "Linear" )
	
	if ( backgroundAlpha >= 255 ) then
	
	aState = true 
	
	elseif ( backgroundAlpha <= 0 ) then
	
	aState = false
	
	end

	dxDrawRectangle(0, 0, 800, 600, tocolor ( 255, 255, 255, backgroundAlpha ), false) 
	
	end
	) 

 

  • Like 2
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...