I am here, because I'm currently struggling with collision detection for my AS3 application. I am loading a bitmap, that represents a room - it has boundaries (walls) and the rest of it is transparent (the floor). I then create a sprite with a circle inside.
I would like my sprite to move within those boundaries and stop at the wall, I'm capable of implementing logics behind that, what I'm asking for is a method to detect the collision with a wall, my whole room is a bitmap, so I guessed I'll just check for the collision with this bitmap, but unfortunately it also counts the transparent parts.
I've done a google research on that, but I only found very complex system which won't work anyway. I'm doing that on learning purposes, so I would like to know how to implement it myself.
Therefore I'm asking if anyone could provide me with piece of code that would check for collision only for non-transparent parts of my bitmap? (Or should I load this png as a vector? how to do so?).
I'm also rotating my "circle", so I guess this should be also considered. I assume I should do bitmap to bitmap check rather than sprite to bitmap?
I have no working code for collisions at all, so I won't provide any.
Should I provide more information please tell me.
Thanks in advance!
@EDIT
this is code I have for my function, it belongs to Room Class.
public function detectCollisionWith(obj:Sprite):Boolean
{
var _bitmapData:BitmapData = new BitmapData(obj.width, obj.height, true, 0);
_bitmapData.draw(obj);
var _bitmap:Bitmap = new Bitmap(_bitmapData);
if (_bitmapData.hitTest(new Point(_bitmap.x, _bitmap.y), 255, this.bitmap, new Point(this.x, this.y), 255))
return true;
return false;
}