[quote]Why translucent? It’s the background, right?
I would guess you’re clearing each frame black anyway, and if so, why not clearing it with a different color and forget about tranlucency? That’s how I did it with duke rogers anyway (in which the background slowly fades to different colors), just a completely opaque fillRect.
[/quote]
Actually, the game uses a custom layered-components system I wrote; it makes it VERY easy to have a complex GUI with lots of independent layers; very easy to add new features, and even new interactive features (which normally tends to be quite tricky in a complex program).
The flash is implemented as an extra layer that is normally just empty (i.e. lets the layers below show through), but then flashes itself when necessary. Easy to code, easy to maintain.
I never clear any frames - I just let the layer below show through, and if the stack of layers isn’t completely opaque for all pixels, you get weird effects a la doom and idnoclip ;).
Basically, I wrote the bits of JLayeredComponent that Sun should have; if you look at JLC, you’ll see that it’s missing loads of basic functionality. I would much prefer that JLayeredComponent were actually a useful classes for users - it appears that the swing designers just thought of it as a building block for creating their classes-with-internal-frames etc; it could have been so much more than that!.
FYI: I created a few classes that, in essence, allow you to stack JComponent’s on top of each other, and get various extra methods that JComponent SHOULD have, but Sun forgot to include (some of which I’ve logged RFE’s for). For instance, although Graphics is specified as “storing the translation”, there’s no clear way (nothing using just Graphics; presumably there IS a way, but it’s probably in the wrong place, and I certainly haven’t found it yet ) to actually read the translation - and this is an ESSENTIAL requirement to writing any GUI where translation is used, because you need to know in order to correctly interpret things like the mouse co-ordinates from MouseEvent’s…