I am making a game where a block that is black is falling down in a white background. My avatar, which is red is dodging the black blocks but if it hits the black block, the game is over. Can someone give me a hand in starting this? I just want the avatar to check if the pixel at the location of the block is black or white. Thanks.
You can read pixel value from Pixmap by using getPixel()
method:
So if you can make some approximation of your object that needs detection then this can be used. I.e. if your object is (almost) square or circle or something like that so you can set like 4 points representing it. Then you can check those 4 points and if any of them is in collision state then your object is also in collision state.
But if you need "pixel precision" and your sprite is i.e. 200x200 pixels then you would need to check for 200x200 = 40 000 pixels, which is of course not possible so you should go for some other option.