PocketMatrix forums

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

Using API to generate special effect..

Hi,
I just browse the API documents but I can't find any special affects that are directly provided by EDGELIB API sets. Such as, fade in/out, flash, scale up/down, shadow, halo, embossment, etc...
Can you suggest an easy way to generate these kinds of special effects?

Thanks!
Hi,

You can create most effects using the EDGELIB BltFast, Blt and FillRect functions. For example, a screenfade can be made by using FillRect with color black and opacity that slowly goes from 0 to 255.

For shadows I suggest using BltFast in combination with a EFX_COLORFILL filter (maybe combine it with EFX_OPACITY to make it transparent). First draw the shadow (move it right and below the sprite a bit) and then the sprite itself.

For the other effects you might need additional graphics.
Hi,
I have a question.
I have E2DSurface (loaded from .BMP file). Some of the pixels on the surface are (255, 0, 255). They should be transparent. I can do:
Code:

surface.SetColorKey(E_RGBX(255, 0, 255));
buffer.BltFast(x, y, &surface;, 0, EFX_COLORKEY);

It works fine. But some other pixels on the surface are (0, 0, 0) and they should be half-transparent. I use them for shadow. How can I get this effect? (some pixels should be transparent, some pixels should be half-transparent, and other pixels should not change).
Hi,

For your effect we recommend using RGBA surfaces. Store the image with your transparent pixels in a PNG and load it on a E2DSurfaceRGBA. You can also load your current image, and use replacecolor to replace black (rgba: 0, 0, 0, 255) to black with 50% transparency (rgba: 0, 0, 0, 128).
Thanks for your reply. Using RGBA surfaces, of course, the obvious option. But I was hoping to use RGB surfaces, because they support the scaling and rotation. But if this is impossible, I have to use RGBA surfaces.
Hi,

If you would like to do a shadow effect, perhaps it's still possible by using RGB surfaces. First blit the sprite with a slight offset using a colorfill (black) filter in combination with 50% opacity. Then blit the sprite normally over it. A good example is to blit the filtered sprite 4 pixels down and to the right.
Hi,

Thanks for your reply. You offered a good solution but my sprites already contain areas marked as a shadow using some color.