<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Labs: Line-Of-Sight</title>
	<atom:link href="http://darylteo.com/blog/2007/11/23/labs-line-of-sight/feed/" rel="self" type="application/rss+xml" />
	<link>http://darylteo.com/blog/2007/11/23/labs-line-of-sight/</link>
	<description>Bits and blobs on anything tech</description>
	<lastBuildDate>Sat, 31 Dec 2011 19:51:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Daryl</title>
		<link>http://darylteo.com/blog/2007/11/23/labs-line-of-sight/comment-page-1/#comment-45148</link>
		<dc:creator>Daryl</dc:creator>
		<pubDate>Tue, 11 Oct 2011 07:08:09 +0000</pubDate>
		<guid isPermaLink="false">http://darylteo.com/blog/2007/11/23/labs-line-of-sight/#comment-45148</guid>
		<description>This is an extremely old post, and I haven&#039;t even touched Flash in the past 2 years :) I have moved on to iPhone development now.

Thanks for your contribution regardless.
Daryl</description>
		<content:encoded><![CDATA[<p>This is an extremely old post, and I haven&#8217;t even touched Flash in the past 2 years <img src='http://darylteo.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I have moved on to iPhone development now.</p>
<p>Thanks for your contribution regardless.<br />
Daryl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Khoo</title>
		<link>http://darylteo.com/blog/2007/11/23/labs-line-of-sight/comment-page-1/#comment-45048</link>
		<dc:creator>John Khoo</dc:creator>
		<pubDate>Sun, 09 Oct 2011 07:50:13 +0000</pubDate>
		<guid isPermaLink="false">http://darylteo.com/blog/2007/11/23/labs-line-of-sight/#comment-45048</guid>
		<description>Hmm...a slightly less laggy way to test for collision might be to use bitmapdata:
/**
 * Pixel Perfect Collision Detection
 * ---------------------
 * VERSION: 1.0.1
 * DATE: 8/23/2011
 * AS3
 * UPDATES AND DOCUMENTATION AT: http://www.FreeActionScript.com
 **/
package utils
{
	import flash.display.BitmapData;
	import flash.display.DisplayObjectContainer;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	public class CollisionTest 
	{
		// vars
		private var _returnValue:Boolean;
		
		private var _onePoint:Point;
		private var _twoPoint:Point;
		
		private var _oneRectangle:Rectangle;
		private var _twoRectangle:Rectangle;
		
		private var _oneClipBmpData:BitmapData;
		private var _twoClipBmpData:BitmapData;
		
		private var _oneOffset:Matrix;
		private var _twoOffset:Matrix;
		
		/**
		 * Simple collision test. Use this for objects that are not rotated.
		 * @param	clip1	Takes DisplayObjectContainer as argument. Can be a Sprite, MovieClip, etc.
		 * @param	clip2	Takes DisplayObjectContainer as argument. Can be a Sprite, MovieClip, etc.
		 * @return	Collision True/False
		 */
		public function simple(clip1:DisplayObjectContainer, clip2:DisplayObjectContainer):Boolean
		{
			_returnValue = false;
			
			_oneRectangle = clip1.getBounds(clip1);
			_oneClipBmpData = new BitmapData(_oneRectangle.width, _oneRectangle.height, true, 0);
			_oneClipBmpData.draw(clip1);
			
			_twoRectangle = clip2.getBounds(clip2);
			_twoClipBmpData = new BitmapData(_twoRectangle.width, _twoRectangle.height, true, 0);
			_twoClipBmpData.draw(clip2);
			
			_onePoint = new Point(clip1.x, clip1.y)
			_twoPoint =  new Point(clip2.x, clip2.y)
			
			if (_oneClipBmpData.hitTest(_onePoint, 255, _twoClipBmpData, _twoPoint, 255))
			{
				_returnValue = true;
			}
			
			return _returnValue;
		}
		
		/**
		 * Complex collision test. Use this for objects that are rotated, scaled, skewed, etc
		 * @param	clip1	Takes DisplayObjectContainer as argument. Can be a Sprite, MovieClip, etc.
		 * @param	clip2	Takes DisplayObjectContainer as argument. Can be a Sprite, MovieClip, etc.
		 * @return	Collision True/False
		 */
		public function complex(clip1:DisplayObjectContainer, clip2:DisplayObjectContainer):Boolean
		{
			_returnValue = false;
			
			_twoRectangle = clip1.getBounds(clip1);
			_oneOffset = clip1.transform.matrix;
			_oneOffset.tx = clip1.x - clip2.x;
			_oneOffset.ty = clip1.y - clip2.y;	
			
			_twoClipBmpData = new BitmapData(_twoRectangle.width, _twoRectangle.height, true, 0);
			_twoClipBmpData.draw(clip1, _oneOffset);		
			
			_oneRectangle = clip2.getBounds(clip2);
			_oneClipBmpData = new BitmapData(_oneRectangle.width, _oneRectangle.height, true, 0);
			
			_twoOffset = clip2.transform.matrix;
			_twoOffset.tx = clip2.x - clip2.x;
			_twoOffset.ty = clip2.y - clip2.y;	
			
			_oneClipBmpData.draw(clip2, _twoOffset);
			
			_onePoint = new Point(_oneRectangle.x, _oneRectangle.y);
			_twoPoint = new Point(_twoRectangle.x, _twoRectangle.y);
			
			if(_oneClipBmpData.hitTest(_onePoint, 255, _twoClipBmpData, _twoPoint, 255))
			{
				_returnValue = true;
			}
			
			_twoClipBmpData.dispose();
			_oneClipBmpData.dispose();
			
			return _returnValue;
		}
		
	}

}
Pardon me if I&#039;m wrong about the lag, I&#039;m still a noob at this.

If you&#039;re wondering how I knew you used hitTestPoint, I decompiled your SWF. Sorr yabout that ;).</description>
		<content:encoded><![CDATA[<p>Hmm&#8230;a slightly less laggy way to test for collision might be to use bitmapdata:<br />
/**<br />
 * Pixel Perfect Collision Detection<br />
 * &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
 * VERSION: 1.0.1<br />
 * DATE: 8/23/2011<br />
 * AS3<br />
 * UPDATES AND DOCUMENTATION AT: <a href="http://www.FreeActionScript.com" rel="nofollow">http://www.FreeActionScript.com</a><br />
 **/<br />
package utils<br />
{<br />
	import flash.display.BitmapData;<br />
	import flash.display.DisplayObjectContainer;<br />
	import flash.geom.Matrix;<br />
	import flash.geom.Point;<br />
	import flash.geom.Rectangle;</p>
<p>	public class CollisionTest<br />
	{<br />
		// vars<br />
		private var _returnValue:Boolean;</p>
<p>		private var _onePoint:Point;<br />
		private var _twoPoint:Point;</p>
<p>		private var _oneRectangle:Rectangle;<br />
		private var _twoRectangle:Rectangle;</p>
<p>		private var _oneClipBmpData:BitmapData;<br />
		private var _twoClipBmpData:BitmapData;</p>
<p>		private var _oneOffset:Matrix;<br />
		private var _twoOffset:Matrix;</p>
<p>		/**<br />
		 * Simple collision test. Use this for objects that are not rotated.<br />
		 * @param	clip1	Takes DisplayObjectContainer as argument. Can be a Sprite, MovieClip, etc.<br />
		 * @param	clip2	Takes DisplayObjectContainer as argument. Can be a Sprite, MovieClip, etc.<br />
		 * @return	Collision True/False<br />
		 */<br />
		public function simple(clip1:DisplayObjectContainer, clip2:DisplayObjectContainer):Boolean<br />
		{<br />
			_returnValue = false;</p>
<p>			_oneRectangle = clip1.getBounds(clip1);<br />
			_oneClipBmpData = new BitmapData(_oneRectangle.width, _oneRectangle.height, true, 0);<br />
			_oneClipBmpData.draw(clip1);</p>
<p>			_twoRectangle = clip2.getBounds(clip2);<br />
			_twoClipBmpData = new BitmapData(_twoRectangle.width, _twoRectangle.height, true, 0);<br />
			_twoClipBmpData.draw(clip2);</p>
<p>			_onePoint = new Point(clip1.x, clip1.y)<br />
			_twoPoint =  new Point(clip2.x, clip2.y)</p>
<p>			if (_oneClipBmpData.hitTest(_onePoint, 255, _twoClipBmpData, _twoPoint, 255))<br />
			{<br />
				_returnValue = true;<br />
			}</p>
<p>			return _returnValue;<br />
		}</p>
<p>		/**<br />
		 * Complex collision test. Use this for objects that are rotated, scaled, skewed, etc<br />
		 * @param	clip1	Takes DisplayObjectContainer as argument. Can be a Sprite, MovieClip, etc.<br />
		 * @param	clip2	Takes DisplayObjectContainer as argument. Can be a Sprite, MovieClip, etc.<br />
		 * @return	Collision True/False<br />
		 */<br />
		public function complex(clip1:DisplayObjectContainer, clip2:DisplayObjectContainer):Boolean<br />
		{<br />
			_returnValue = false;</p>
<p>			_twoRectangle = clip1.getBounds(clip1);<br />
			_oneOffset = clip1.transform.matrix;<br />
			_oneOffset.tx = clip1.x &#8211; clip2.x;<br />
			_oneOffset.ty = clip1.y &#8211; clip2.y;	</p>
<p>			_twoClipBmpData = new BitmapData(_twoRectangle.width, _twoRectangle.height, true, 0);<br />
			_twoClipBmpData.draw(clip1, _oneOffset);		</p>
<p>			_oneRectangle = clip2.getBounds(clip2);<br />
			_oneClipBmpData = new BitmapData(_oneRectangle.width, _oneRectangle.height, true, 0);</p>
<p>			_twoOffset = clip2.transform.matrix;<br />
			_twoOffset.tx = clip2.x &#8211; clip2.x;<br />
			_twoOffset.ty = clip2.y &#8211; clip2.y;	</p>
<p>			_oneClipBmpData.draw(clip2, _twoOffset);</p>
<p>			_onePoint = new Point(_oneRectangle.x, _oneRectangle.y);<br />
			_twoPoint = new Point(_twoRectangle.x, _twoRectangle.y);</p>
<p>			if(_oneClipBmpData.hitTest(_onePoint, 255, _twoClipBmpData, _twoPoint, 255))<br />
			{<br />
				_returnValue = true;<br />
			}</p>
<p>			_twoClipBmpData.dispose();<br />
			_oneClipBmpData.dispose();</p>
<p>			return _returnValue;<br />
		}</p>
<p>	}</p>
<p>}<br />
Pardon me if I&#8217;m wrong about the lag, I&#8217;m still a noob at this.</p>
<p>If you&#8217;re wondering how I knew you used hitTestPoint, I decompiled your SWF. Sorr yabout that <img src='http://darylteo.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
</channel>
</rss>

