私は、私の宇宙ゲームで飛んでいるオブジェクトを色づけしようとすると大きな問題を抱えました。AS3のcolormatrixで着色してください - 助けてください!
私がそれらを撃って打つと、敵の敵が点滅します。グラフィックスは事前レンダリングされています(つまり、回転配列と機能があり、オブジェクトの度合いと回転が保存され、パフォーマンスが向上します)。
だから私のアイデアは、追加の色付けの機能を使って回転機能を強化することでした。着色されたAND回転オブジェクトは、通常の回転オブジェクトから離れて格納されます。これを達成するために、ネストされた配列を作成しました。 行1に360オブジェクトの回転グラフィックがあり、2行には回転したオブジェクトの360グラフィックスがあります。
問題:着色は機能しますが、回転はしません(常に0度です)。私を助けてください - 私はそれがなぜ動かないのか何時間もわかっていたので、私はあきらめました。誰かが問題を見つけることができれば、とても涼しいでしょう!どうもありがとうございました!
public function createRotationWithColorBlitArrayFromBD(sourceBitmapData:BitmapData, inc:int, offset:int = 0):Array
{
trace("sourceBitmapData.width=" + sourceBitmapData.width);
trace("sourceBitmapData.height=" + sourceBitmapData.height);
tileList = [];
tileListSec = [];
levelArray = [];
var rotation:int = offset;
while (rotation < (360 + offset))
{
var angleInRadians:Number = Math.PI * 2 * (rotation/360);
var rotationMatrix:Matrix = new Matrix();
rotationMatrix.translate(-sourceBitmapData.width * .5, -sourceBitmapData.height * .5);
rotationMatrix.rotate(angleInRadians);
rotationMatrix.translate(sourceBitmapData.width * .5, sourceBitmapData.height * .5);
var matrixImage:BitmapData = new BitmapData(sourceBitmapData.width, sourceBitmapData.height, true, 0x00000000);
matrixImage.draw(sourceBitmapData, rotationMatrix);
tileList.push(matrixImage.clone());
var colorMatrix:ColorMatrixFilter = new ColorMatrixFilter (
[1, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 1, 0]);
matrixImage.applyFilter(sourceBitmapData, sourceBitmapData.rect, point0, colorMatrix);
tileListSec.push(matrixImage.clone());
rotation += inc;
matrixImage.dispose();
matrixImage = null;
rotationMatrix = null;
}
levelArray = [tileList, tileListSec];
return(levelArray);
}
非常にありがとうございます!あなたはこの答えで私を助け、私の人生を楽にしました!本当にありがとう!:) – drpelz
こんにちは!嬉しいこと:)サイトのユーザー評価を向上させるために、私の回答に「受け入れ済み」と記入してください。 –
チップをありがとう。やったよ。:) – drpelz