Screen Fade

BlitzMax Forums/BlitzMax Programming/Screen Fade

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Oh you mean like this (this is old code but I think it still works on the latest version of BMAX):
DebugLog "MOD_ImageFade.bmx"

' Copyright Indiepath Ltd, this source is not public domain. Use at your own risk!

Global iFadeTList:TList = New TList

Type iFade
	Field Image:TImage
	Field In:Int
	Field Out:Int
	Field Time:Int
	Field Alpha:Double
	Field Timer:Timer
	Field x:Double
	Field y:Double
	Field dx:Double
	Field dy:Double
	
		Method New ()
   	         	If iFadeTList = Null Then iFadeTList = New TList
            	iFadeTList.AddLast Self
    	End Method	

		'----------------------------------------------------------------
		
		Function KillAll()
				While (Not iFadeTList.IsEmpty())
					
					iFadeTList.RemoveLast()
				Wend
		'		FlushMem
		End Function
	
		'----------------------------------------------------------------
		
		Function Destroy(i:iFade)
		     	iFadeTList.Remove i
				i = Null
		'		FlushMem
        End Function

		'----------------------------------------------------------------
		
		Function Create:iFade(img:TImage,x:Double,y:Double,dx:Double,dy:Double,in:Int,Out:Int,Time:Int)
				Local i:iFade
				i:iFade = New iFade
				i.Image = img
				i.x = x
				i.y = y
				i.dx = dx
				i.dy = dy
				i.in = in
				i.out = out
				i.time = time
				i.alpha = 0
				i.Timer = Timer.Create(i.Time)
				Return i
			
		End Function
		
		'----------------------------------------------------------------
		
		Method Update()
				SetScale(1,1)
				
				Local now:Int = self.Timer.GetValue()
			
				Select True
				
					Case now < 10
						Timer.Destroy(self.Timer)
						Destroy(Self)
						Return False
				
					Case now < self.out
						self.Alpha = (Float(now) / Float(self.out))
						
					Case now < (self.Time - self.in)
						self.alpha = 1
						
					Case  now < self.time
						self.Alpha = 1 - (Float(now - (self.time-self.in)) / Float(self.in))
						
				End Select
				SetBlend(SOLIDBLEND)
				SetAlpha(self.alpha)
				SetBlend(ALPHABLEND)
				DrawImageRect(self.Image,self.x ,self.y ,self.dx ,self.dy )
				
			End Method
			
			'----------------------------------------------------------------
			
			Function UpdateAll()
				Local i:iFade
				Local count:Byte = False
				For i:iFade = EachIn iFadeTList
					Count = True
					i.Update()
				Next
				Return Count
			End Function
			
			'----------------------------------------------------------------
			
			Method RunFade()
				
				While self.Timer.GetValue() > 10
					Cls
					self.Update()
					Flip
					Timer.UpdateAll()				
				Wend
				
			End Method
				
End Type