今天我的问题如下:
我有一个游戏,其中一个阶段的是,你必须通过对娃娃的身体防护霜。我已经有这样的效果(如下图),我使用的是alpha滤镜结合所绘制的面具。
I have a game, and one of the phases is that you have to pass a "protective cream" on the doll's body. I already have this effect (image below), I'm using an alpha filter combined with a mask that is drawn.
我不知道我该怎么做20秒的比赛后要检查,如果用户已经填补了口罩100%
I wonder how can I do to be checking after 20 seconds of the game, if the user has filled 100% of the masks ...
我的code是这样(原谅我,我是初学者,巴西...任何问题问我):
My code is this (forgive me, I am beginner and Brazilian ... any questions ask me):
stop();
import flash.display.Shape;
import flash.events.Event;
import flash.display.BlendMode;
import flash.display.BitmapData;
import flash.utils.Timer;
var tempoFase2:Timer = new Timer(10000, 1);
var corpo_creme:MovieClip = new corpo_mask();
addChild(corpo_creme);
corpo_creme.x = corpo_branco.x;
corpo_creme.y = corpo_branco.y;
setChildIndex(corpo_branco, 1);
setChildIndex(cabeca, 3);
setChildIndex(corpo_creme, 2);
var drawing:Shape = new Shape();
addChild(drawing);
corpo_creme.mask = drawing;
corpo_branco.blendMode = BlendMode.LAYER;
stage.addEventListener(MouseEvent.MOUSE_MOVE,draw);
function draw(e:Event):void {
drawing.graphics.beginFill(0xFFFFFF);
drawing.graphics.drawCircle(mouseX,mouseY,30);
drawing.graphics.endFill();
}
感谢ü。
尝试这种解决方案:
http://stackoverflow.com/a/15354416/1627055
基本上,你运行 BitmapData.threshold()
对类型的面膜的BitmapData 。您也可以绘制的相关部分的
绘图
在一个临时的BitmapData 对象,做同样的伎俩,确保虽然你的算法将统计不包括在您的绘图作为填充区域 - 您可以通过创建实现这一点位图数据pre-填充白色
Basically, you run BitmapData.threshold()
against a mask of type BitmapData
. You can also draw the relevant portion of your drawing
over a temporary BitmapData
object and do the same trick, make sure though that your algorithm will count the areas that are not covered by your drawing as filled - you can achieve this by creating the bitmap data pre-filled with white.