Page 1 of 1

Need help fading in a sprite

Posted: Mon Feb 04, 2013 6:43 pm
by InnocentSam
Hey there,

I'm trying to make a sprite slowly fade in onto the player's screen. Like the gasmask overlay, but with another one, and it comes in slowly. I have a timer that I can hook it into, but despite doing this, it comes up as the normal sprite no matter what I do.

Code: Select all

	InfectTexture = LoadTexture("GFX\InfectOverlay.jpg", 1)
	InfectOverlay = CreateSprite(Camera)
	ScaleSprite(InfectOverlay, Max(GraphicWidth / 1024.0, 1.0), Max(GraphicHeight / 1024.0 * 0.8, 0.8))
	EntityTexture(InfectOverlay, InfectTexture)
	EntityBlend (InfectOverlay, 2)
	EntityFX(InfectOverlay, 1)
	EntityOrder InfectOverlay, -1003
	MoveEntity(InfectOverlay, 0, 0, 1.0)
	EntityAlpha(InfectOverlay, Bloodloss2/100)
	HideEntity(InfectOverlay)
I've divided my timer by 100 so it'll be between 0 and 1 (yeah I hijacked the bloodloss timer ^.^)

My timer:

Code: Select all

Bloodloss2 = Min(Bloodloss2 + (Min(1,3.5)/300.0)*FPSfactor,125)
Anyone have any tips or point out my errors?

Thanks.

Re: Need help fading in a sprite

Posted: Mon Feb 04, 2013 8:47 pm
by juanjp600
InnocentSam wrote: EntityBlend (InfectOverlay, 2)
Blitz3D manual wrote:The alpha value has no effect with multiplicative blending (the blend mode you are using).
Try changing the blend mode to 1 (alpha) or 3 (add).

Re: Need help fading in a sprite

Posted: Mon Feb 04, 2013 9:34 pm
by InnocentSam
I tried it with 3 and set the alpha to 1, it worked.

Changed the alpha to my timer variable, and nothing. Even when the timer hit 1.

EDIT: Just had an idea, I can just put a load of "If Bloodloss2 > 2.5 Then EntityAlpha blah" depending on how much I want it to fade. It might be a bit hacky, but it's better than it not working at all.