私はベースの画像といくつかのスプライトを基本画像のムービークリップ...スプライトの一部は、ActionScript3のグラフィックスAPIを使用して描画することができます。スプライト上に描画することはできますが、不要な図面の一部を削除できるブラシのような消しゴムを作成することはできません。私はアルファを使ってみるが、それはうまくいきません
私はそれについてgoogledし、解決策を考え出す:
1)ラインビットマップスタイル... このソリューションは最高のものではありません。私のスプライトは移動できますので、linebitmapstyleを使用すると、イメージからスプライトにピクセルを描画しますが、スプライトが移動した場合、描画されたピクセルは変化しません。
2)マスキングが私のために働かないかもしれない....
消しゴムを作る最善の方法は何ですか?
回答:
回答№1の場合は3むしろ、ビットマップを使って(もちろんスケーラブルなベクターグラフィックスを行う必要がない限り)操作が簡単です。シェイプを描画するには、グラフィックスAPIを使用してシェイプを作成することができます。
これを行うには、「ダミーの」スプライト(または別のスプライト IBitmapDrawable
実装)を使用してグラフィックスを作成し、それらをグラフィックスにコピーします BitmapData
その bitmapData.draw()
関数。この方法では、たとえばオプションを使用して描画することができます BlendMode.ERASE
形状のピクセルを除去する。
例(私の頭の上から):
// creates a bitmap data canvas
var bitmapData:BitmapData = new BitmapData(500, 500);
// creates a bitmap display object to contain the BitmapData
addChild(new Bitmap(bitmapData));
// creates a dummy object to draw and draws a 10px circle
var brush:Sprite = new Sprite(); // note this is not even added to the stage
brush.graphics.beginFill(0xff0000);
brush.graphics.drawCircle(10, 10, 10);
// the matrix will be used to position the "brush strokes" on the canvas
var matrix:Matrix = new Matrix();
// draws a circle in the middle of the canvas
matrix.translate(250, 250);
bitmapData.draw(brush, matrix
// translates the position 5 pixels to the right to slightly erase the previously
// drawn circle creating a half moon
matrix.translate(5, 0);
bitmapData.draw(brush, matrix,null,BlendMode.ERASE);