I'm trying to find out if there are empty pixels in a certain location using getPixel32 from the OpenFL framework, but it always returns 0.
This is my code:
import { Bitmap, BitmapData } from "openfl";
export default class Tile extends Bitmap {
constructor(param1: BitmapData) {
super(param1);
}
public isEmpty(x: number, y: number): boolean {
const pixel32 = this.bitmapData.getPixel32(x, y);
console.log(pixel32); // return 0
return ((pixel32 >> 24) & 255) <= 150;
}
}
An interesting thing, instead of using getPixel32 and using getPixels it looks like it works perfectly:
But I don't know if this is the best method