Skip to main content
May 2, 2013
Answered

Fog of war

  • May 2, 2013
  • 2 replies
  • 1163 views

I have been trying to implement fog of war for a game I'm making. I have tried several approaches but none have turned out successful.

Alpha tiles:

   This was the first thing I tried, unfortunately covering the screen in this many tiles all with alpha levels caused too much lag and I abandoned it.

Vector drawings and blend mode:

  Next I tried drawing a dark rectangle and Blendmode.ERASE in out the things I want the player to see. With more than a few light sources this becomes laggy and becomes horrible if I apply a blur filter.

Masks:

  Finally I tried masks, unfortunately they aren't very flexible(one mask per movieClip and such.) They didn't fit the bill.

Do you have any alternative suggestions/methods to make these work?

This topic has been closed for replies.
Correct answer Amy Blankenship

Create a new transparent BitmapData , then use copyPixels() or draw() to put your foh on it. Check out http://www.developria.com/2010/02/dealing-with-bitmapdata.html for more info.

Some examples from my blog of working with pixels that you might find useful http://flexdiary.blogspot.com/search/label/BitmapData

2 replies

Amy Blankenship
Amy BlankenshipCorrect answer
Legend
May 3, 2013

Create a new transparent BitmapData , then use copyPixels() or draw() to put your foh on it. Check out http://www.developria.com/2010/02/dealing-with-bitmapdata.html for more info.

Some examples from my blog of working with pixels that you might find useful http://flexdiary.blogspot.com/search/label/BitmapData

kglad
Community Expert
Community Expert
May 2, 2013

you should be able to use alpha tiles if you enable all tiles cacheAsBitamp property.