/ Published in: ActionScript 3
Simple snippet to check is Flixel's flxObjects position according to a rectangle.
It will return true if it's inside the rectangle, false if not.
Very basic primitive box collision checking.
It will return true if it's inside the rectangle, false if not.
Very basic primitive box collision checking.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
private function isInRect(ob:FlxObject,rect:Rectangle):Boolean { if ((ob.right) >= rect.x && (ob.left) <= (rect.x + rect.width) && ob.bottom >= rect.y && ob.bottom <= rect.y + rect.height // change bottom to top if you allow objects feet should go beyond rectangles bottom. ) { return true; }else { return false; } }