Return to Snippet

Revision: 37890
at December 19, 2010 09:58 by godstroke


Updated Code
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;
			}
		}

Revision: 37889
at December 19, 2010 09:55 by godstroke


Initial Code
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 
			) {
				return true;
			}else {
				return false;
			}
		}

Initial URL

                                

Initial Description
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.

Initial Title
Check if the FlxObject is inside the given rectangle

Initial Tags
flash

Initial Language
ActionScript 3