Fade Image (screen) to black

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
JetSpike
Posts: 8
Joined: Mon Sep 19, 2005 2:38 am

Fade Image (screen) to black

Post by JetSpike »

I have created an image like this:

imgAlpha = Image.createEmpty(480,272)
clrAlpha = Color.new(0,0,0,150)
imgAlpha:fillRect(0,0,479,271,clrAlpha)

So now I have a black rectangle the size of the screen with an alpha value of 150.

I have another image:

imgToFade = Image.createEmpty(480,272)
imgToFade:clear(clrBlack)

I then draw some graphics to imgToFade.

Now what want to do is blit imgAlpha on to imgToFade, once every loop, so the effect will be imgToFade will go completely black if I don't draw anything new. However, when I try to blit imgAlpha on to imgToFade, it doesn't blend properly. If I set an alpha value of 255, then it works, but I want to use a lower value so if fades gradually.

I know the imgAlpha works correctly because if I do this:

screen:clear(clrBlack)
screen:blit(0,0,imgToFade,true)
screen:blit(0,0,imgAlpha,true)

Then the graphics on imgToFade are blended appropriately. But I want to have it apply the blend on to imgToFade itself so eventually it goes to black.

Any ideas why this isn't happening the way I expect it to?
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Post by fullerlee »

I've found that alpha values of 0 or 255 are the only ones that work correctly.
JetSpike
Posts: 8
Joined: Mon Sep 19, 2005 2:38 am

Post by JetSpike »

Yeah, it's weird, only two values work when blitting to an image, but when I blit to the screen directly, I can use any value I want.
Post Reply