Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Bitmap, blitting and masks

Guest
Aug 06, 2013 Aug 06, 2013

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

TOPICS
ActionScript
684
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 06, 2013 Aug 06, 2013

why not make the blitted bit beneath the semi transparent element totally transparent?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 06, 2013 Aug 06, 2013

That would work, but it doesn't look good

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 06, 2013 Aug 06, 2013

what about it is not perfect?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 06, 2013 Aug 06, 2013

If, for example im trying to draw a window. I would like a faint white transparency rather than completely see-through.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 06, 2013 Aug 06, 2013
LATEST

yes, so what's the problem?  the topmost bitmap shows the semi-transparent window and the bottommost shows nothing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines