How to detect if the area was 100% painted in as3

前端 未结 3 1278
青春惊慌失措
青春惊慌失措 2020-12-11 23:46

I´m making a game that simulates an industry of pan, and one of the process is Painting.

What I want to do is to let the player paint the pan, but i don´t want it to

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-11 23:57

    You can iterate over the pixels on your BitmapData and use getPixel() to check if the color of all those pixels is not white. If a white one is found, the image is not fully painted.

    Something like this:

    function containsWhite(bitmapData:BitmapData):Boolean
    {
        for(var c:int = 0; c < bitmapData.width; c++)
        {
            for(var r:int = 0; r < bitmapData.height; r++)
            {
                // Check if pixel is white.
                if(bitmapData.getPixel(c, r) >= 0xFFFFFF)
                {
                    return true;
                }
            }
        }
    
        return false;
    }
    

提交回复
热议问题