Copy link to clipboard
Copied
I have a 2d isometric game map that is blitted into a single Bitmap. I also then have a character MovieClip animation on top that can walk around the screen.
In certain areas there are things (walls etc) on the game map that must appear above the character, not beneath. To achieve this, I have a transparent bitmap covering the character and when an object needs to appear above the character I add that object's bitmapData to this bitmap. Whenever the character moves the bitmap is cleared and redrawn. For example, my display order could be: gameMap > character > a wall piece .
My problem occurs when the user goes behind an element with transparency. I end up drawing the transparent element ontop of the copy in the game map, which makes the element appear less transparent.
I am thinking I would like to try some sort of mask. For example, I could use the transparent bitmap above the character as a mask for the entire game map beneath and do something like 'underneath the non-transparent areas of the bitmap above the character, make all the pixels in the game map bitmap transparent/hidden'.
I have tried doing this by doing bitmapData.fillRect(rect beneath character, transparent pixel) on the gameMap underneath which works well in removing the elements, but then the gamemap must be redrawn again afterwards which causes quite the performance hit.
Any ideas? Thanks
Copy link to clipboard
Copied
why not make the blitted bit beneath the semi transparent element totally transparent?
Copy link to clipboard
Copied
That would work, but it doesn't look good
Copy link to clipboard
Copied
what about it is not perfect?
Copy link to clipboard
Copied
If, for example im trying to draw a window. I would like a faint white transparency rather than completely see-through.
Copy link to clipboard
Copied
yes, so what's the problem? the topmost bitmap shows the semi-transparent window and the bottommost shows nothing.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now