matrix - Actionscript 3 - How To Check A Random Pixel Of A Sprite -
i have sprite drawn in random , complicated way. pixels either transparent or not. , need check if pixel new point(10, -5) transparent or not.
how can ?
- this not collision detection.
- i draw in negative area of sprite graphics. not centered.
solution:
the main problem drawing in negative area. figured out myself:
var bitmapdata: bitmapdata = new bitmapdata(sprite.width, sprite.height, true, 0x0); var rect: rectangle = sprite.getbounds(sprite); var mat: matrix = new matrix(); mat.translate(-rect.left, -rect.top); bitmapdata.draw(sprite, mat); bitmapdata.getpixel32(xcoordtotest - rect.left, ycoordtotest - rect.top); // etc
create new bitmapdata object , draw sprite onto it. check desired bitmapdata pixel.
var bitmapdata:bitmapdata = new bitmapdata(mysprite.width,mysprite.height,true,0x00000000); bitmapdata.draw(mysprite); bitmapdata.getpixel32(10,5);
Comments
Post a Comment