PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

About Alpha

I found the alpha setting (SetBlending), and I'm trying to use it to shade a sprite (blit an image, then blit a translucent black square over it). However, the SetBlending seems to make the images fade in over time, and they all come up red. Am I using the wrong function? Has anybody tried to do this shading before?
You are using the correct function. I do :-
Code:

m_display->SetBlending(Alpha);// level of alpha blending
m_display->Blit(Xpos,Ypos,SpriteData,&FrameArray;[FrameCount]);//draw 1 frame
m_display->SetBlending(0xFF);//no blend


What's the black square doing to fade the sprite? Are you wanting to both darken and fade the sprite.
I'm trying to fog out a land tile (Fog of war). By blitting a translucently dark square over a land tile, I figure I can make the image look darker.

What are you using the blend for? The same kind of thing?
Conan · 05 Jul 2002, 21:20 UTC — what I'm using the alpha blend for
My PocketFrog beginner's guide chapter 4 is about sprites & I have a simple sprite class which has alpha blending as one variable. I fade out one of the sprites in the demo.

I also use blending to fade out text in the opening titles.

Another method would be to darken the image itself by manipulating it's bits but there's much more work in doing that. You should be able to get your idea to work fine.
To darken a rectangle, you can simply use FillRect() & SetBlending() together.

Example:

display()->SetBlending( 128 );
display()->FillRect( Rect(100,50,110,60), Color(0,0,0) );
Actually, I found an even better way (at least, I THINK it's better).

I created a pixel shader based on the ir_shader that you guys were talking about in a previous thread. My pixel shader just takes the current light value, and ramps down all RGB values for each pixel. It's no real framerate hit, and gets great-looking results.

Thanks guys.