Hello,
I’ve run into an issue where the BitmapData.Draw() method seems to not always produce a reliable result.
Basically all i am trying to do is drop an object from the top of the screen and when it comes into contact with an object at the bottom of the screen a subtraction of pixels should occur on the bottom object.
I’ve got all of this working so far, the one issue i seem to be having is when i reset the falling images y coordinate and it comes in contact with the bottom object again, the subtraction of pixels doesn’t always occur.
Here’s the code that’s causing me troubles:
public function dropFromSky(e:Event)
{
for (var i:int=0; i<10; i++)
{
if (baseBmpData.hitTest(new Point(baseBmp.x,baseBmp.y),0x00,new Point(missileBitmap.x,missileBitmap.y)))
{
missileBitmap.y++;
missileMatrix = new Matrix();
missileMatrix.translate(baseBmp.x,baseBmp.y);
missileMatrix.tx = (missileBitmap.x - baseBmp.x);
missileMatrix.ty = (missileBitmap.y - baseBmp.y);
// public function draw(source:IBitmapDrawable, matrix:Matrix = null, colorTransform:flash.geom:ColorTransform = null, blendMode:String = null, clipRect:Rectangle = null, smoothing:Boolean = false):void
baseBmpData.draw(missileBitmap, missileMatrix, null, BlendMode.ERASE, null, true);
missileBitmap.x = Utils.rand(60, 140);
missileBitmap.y = 0;
}
else
{
missileBitmap.y++;
}
}
}
At this point I don’t know if it’s the Matrix that’s being created is incorrect or the code itself is overlooking something.
Any suggestions as to what I’m missing would be greatly appreciated.
best regards,
rise4peace