0

ベース イメージと、ベース イメージ ムービークリップの上にいくつかのスプライトがあります...いくつかのスプライトは、ユーザーが actionscript 3 のグラフィックス API を使用して描画できます。スプライトに描画することはできますが、消しゴムを作成できません不要な描画の一部を削除できるブラシのようなもの。Alpha を使用してみましたが、うまくいきません

私はそれについてグーグルで検索し、解決策を考え出しました:

1) Linebitmapstyle ... このソリューションは最適なソリューションではありません。スプライトを移動できるため、linebitmapstyle を使用すると、画像からスプライトにピクセルが描画されますが、スプライトが移動した場合、描画されたピクセルは変更されません。

2)マスキングもうまくいかないかもしれません....

消しゴムを作成する最良の方法は何ですか

4

1 に答える 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);
于 2009-10-09T00:00:05.380 に答える