<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jesse Gomez &#187; code stuffs</title>
	<atom:link href="http://thecoho.net/category/blog/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://thecoho.net</link>
	<description>Swimming upstream since 1978</description>
	<lastBuildDate>Thu, 24 Jun 2010 15:24:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple Quickbox2d Sensors</title>
		<link>http://thecoho.net/2010/06/14/simple-quickbox2d-sensors/</link>
		<comments>http://thecoho.net/2010/06/14/simple-quickbox2d-sensors/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 16:12:00 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[code stuffs]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[box2d]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[quickbox2d]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://thecoho.net/?p=693</guid>
		<description><![CDATA[Hey, wouldn&#8217;t be nice if you could make sensors easily in quickbox2d (which is already fantastic and easy). Well, you can, and here&#8217;s how, really easily. I&#8217;d post the source code, but if you haven&#8217;t figured it out by yourself, you  might need the practice tinkering (besides Zevan will add it soon, I&#8217;m sure). This [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://thecoho.net/wp-content/uploads/2010/06/sensorpic.jpg" rel="shadowbox[post-693];player=img;"><img class="alignright size-medium wp-image-709" title="sensorpic" src="http://thecoho.net/wp-content/uploads/2010/06/sensorpic-250x262.jpg" alt="sensorpic" width="250" height="262" /></a>Hey, wouldn&#8217;t be nice if you could make sensors easily in quickbox2d (which is already fantastic and easy). Well, you can, and here&#8217;s how, really easily. I&#8217;d post the source code, but if you haven&#8217;t figured it out by yourself, you  might need the practice tinkering (besides Zevan will add it soon, I&#8217;m sure). This is painless, I promise.</p>
<p>If you don&#8217;t know what a sensor is, or why you&#8217;d want one &#8211; think of it as a physics object that detects collision but doesn&#8217;t actually affect the movement of anything its collides with &#8211; like passing through a ghost. No category or mask bits needed here, just a simple &#8220;true&#8221; or  &#8221;false&#8221;.</p>
<p>here&#8217;s how to add it to quickbox2d:</p>
<p>OVERVIEW:</p>
<p>you are going to open and add one tiny line of code to 3 files.</p>
<p>Step 1) open com.actionsnippet.QuickObject.as</p>
<p>Step) find the function &#8220;defineDefaults&#8221; should look something like this:</p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> defineDefaults<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
defaults = <span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">,</span> linearDamping<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><br />
angularDamping<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> isBullet<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span><br />
fixedRotation<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span><br />
allowSleep<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span><br />
isSleeping<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span><br />
scaleSkin<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span><br />
density<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1.0</span><span style="color: #000066; font-weight: bold;">,</span> friction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">,</span> restitution<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">angle</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.0</span><span style="color: #000066; font-weight: bold;">,</span><br />
maskBits<span style="color: #000066; font-weight: bold;">:</span>0xFFFF<span style="color: #000066; font-weight: bold;">,</span> categoryBits<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> groupIndex<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><br />
draggable<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span><br />
lineColor<span style="color: #000066; font-weight: bold;">:</span>0x000000<span style="color: #000066; font-weight: bold;">,</span> lineAlpha<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><br />
lineThickness<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><br />
fillColor<span style="color: #000066; font-weight: bold;">:</span>0xCCCCCC<span style="color: #000066; font-weight: bold;">,</span> fillAlpha<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>When you create an object, you pass parameters. these are the default parameters and we need to do as add &#8220;, isSensor:false&#8221; at the end so it looks like this</p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> defineDefaults<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
defaults = <span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">,</span> linearDamping<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><br />
angularDamping<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> isBullet<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span><br />
fixedRotation<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span><br />
allowSleep<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span><br />
isSleeping<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span><br />
scaleSkin<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span><br />
density<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1.0</span><span style="color: #000066; font-weight: bold;">,</span> friction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">,</span> restitution<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">angle</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.0</span><span style="color: #000066; font-weight: bold;">,</span><br />
maskBits<span style="color: #000066; font-weight: bold;">:</span>0xFFFF<span style="color: #000066; font-weight: bold;">,</span> categoryBits<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> groupIndex<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><br />
draggable<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span><br />
lineColor<span style="color: #000066; font-weight: bold;">:</span>0x000000<span style="color: #000066; font-weight: bold;">,</span> lineAlpha<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><br />
lineThickness<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><br />
fillColor<span style="color: #000066; font-weight: bold;">:</span>0xCCCCCC<span style="color: #000066; font-weight: bold;">,</span> fillAlpha<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><br />
isSenor<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>1 of 3 completed. Now lets add a couple of tiny bits of code to the &#8220;BoxObject.as&#8221; and &#8220;CircleObject.as&#8221; files as well</p>
<p>BoxObject code: &#8220;boxDef.isSensor = p.isSensor;&#8221; see example below</p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> build<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> p<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = params<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>p<span style="color: #000066; font-weight: bold;">.</span>skin <span style="color: #0033ff; font-weight: bold;">is</span> <a href="http://www.google.com/search?q=displayobject%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:displayobject.html"><span style="color: #004993;">DisplayObject</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
bodyDef<span style="color: #000066; font-weight: bold;">.</span>userData = p<span style="color: #000066; font-weight: bold;">.</span>skin<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> t<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = p<span style="color: #000066; font-weight: bold;">.</span>skin<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rotation</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
p<span style="color: #000066; font-weight: bold;">.</span>skin<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rotation</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = p<span style="color: #000066; font-weight: bold;">.</span>skin<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">30</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = p<span style="color: #000066; font-weight: bold;">.</span>skin<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">30</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
p<span style="color: #000066; font-weight: bold;">.</span>skin<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rotation</span> = t<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000;">&#41;</span> p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span> p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> boxDef<span style="color: #000066; font-weight: bold;">:</span>b2PolygonDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2PolygonDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
shapeDef = boxDef<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> hw<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> hh<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br />
boxDef<span style="color: #000066; font-weight: bold;">.</span>SetAsBox<span style="color: #000000;">&#40;</span>hw<span style="color: #000066; font-weight: bold;">,</span> hh<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
boxDef<span style="color: #000066; font-weight: bold;">.</span>density = p<span style="color: #000066; font-weight: bold;">.</span>density<span style="color: #000066; font-weight: bold;">;</span><br />
boxDef<span style="color: #000066; font-weight: bold;">.</span>friction = p<span style="color: #000066; font-weight: bold;">.</span>friction<span style="color: #000066; font-weight: bold;">;</span><br />
boxDef<span style="color: #000066; font-weight: bold;">.</span>restitution = p<span style="color: #000066; font-weight: bold;">.</span>restitution<span style="color: #000066; font-weight: bold;">;</span><br />
boxDef<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">filter</span><span style="color: #000066; font-weight: bold;">.</span>maskBits = p<span style="color: #000066; font-weight: bold;">.</span>maskBits<span style="color: #000066; font-weight: bold;">;</span><br />
boxDef<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">filter</span><span style="color: #000066; font-weight: bold;">.</span>categoryBits = p<span style="color: #000066; font-weight: bold;">.</span>categoryBits<span style="color: #000066; font-weight: bold;">;</span><br />
boxDef<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">filter</span><span style="color: #000066; font-weight: bold;">.</span>groupIndex = p<span style="color: #000066; font-weight: bold;">.</span>groupIndex<span style="color: #000066; font-weight: bold;">;</span><br />
boxDef<span style="color: #000066; font-weight: bold;">.</span>isSensor = p<span style="color: #000066; font-weight: bold;">.</span>isSensor<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// &amp;lt;------ HERE IT IS!</span></div></td></tr></tbody></table></div>
<p>CircleObject code: &#8220;circDef.isSensor = p.isSensor;&#8221; see example below</p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">protected</span> override <span style="color: #339966; font-weight: bold;">function</span> build<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> p<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = params<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> circDef<span style="color: #000066; font-weight: bold;">:</span>b2CircleDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2CircleDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
shapeDef = circDef<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>p<span style="color: #000066; font-weight: bold;">.</span>skin <span style="color: #0033ff; font-weight: bold;">is</span> <a href="http://www.google.com/search?q=displayobject%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:displayobject.html"><span style="color: #004993;">DisplayObject</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
bodyDef<span style="color: #000066; font-weight: bold;">.</span>userData = p<span style="color: #000066; font-weight: bold;">.</span>skin<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>p<span style="color: #000066; font-weight: bold;">.</span>radius<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
p<span style="color: #000066; font-weight: bold;">.</span>radius = p<span style="color: #000066; font-weight: bold;">.</span>skin<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">60</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>p<span style="color: #000066; font-weight: bold;">.</span>radius<span style="color: #000000;">&#41;</span> p<span style="color: #000066; font-weight: bold;">.</span>radius = <span style="color: #000066; font-weight: bold;">.</span>5<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
circDef<span style="color: #000066; font-weight: bold;">.</span>radius = p<span style="color: #000066; font-weight: bold;">.</span>radius<span style="color: #000066; font-weight: bold;">;</span><br />
circDef<span style="color: #000066; font-weight: bold;">.</span>density = p<span style="color: #000066; font-weight: bold;">.</span>density<span style="color: #000066; font-weight: bold;">;</span><br />
circDef<span style="color: #000066; font-weight: bold;">.</span>friction = p<span style="color: #000066; font-weight: bold;">.</span>friction<span style="color: #000066; font-weight: bold;">;</span><br />
circDef<span style="color: #000066; font-weight: bold;">.</span>restitution = p<span style="color: #000066; font-weight: bold;">.</span>restitution<span style="color: #000066; font-weight: bold;">;</span><br />
circDef<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">filter</span><span style="color: #000066; font-weight: bold;">.</span>maskBits = p<span style="color: #000066; font-weight: bold;">.</span>maskBits<span style="color: #000066; font-weight: bold;">;</span><br />
circDef<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">filter</span><span style="color: #000066; font-weight: bold;">.</span>categoryBits = p<span style="color: #000066; font-weight: bold;">.</span>categoryBits<span style="color: #000066; font-weight: bold;">;</span><br />
circDef<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">filter</span><span style="color: #000066; font-weight: bold;">.</span>groupIndex = p<span style="color: #000066; font-weight: bold;">.</span>groupIndex<span style="color: #000066; font-weight: bold;">;</span><br />
circDef<span style="color: #000066; font-weight: bold;">.</span>isSensor = p<span style="color: #000066; font-weight: bold;">.</span>isSensor<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// HERE IT IS!!!</span></div></td></tr></tbody></table></div>
<p>so, now, anytime you want an object to be a sensor, just tell it so on creation.<br />
Examples:</p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sim<span style="color: #000066; font-weight: bold;">.</span>addBox<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>someNumber<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span>someNumber<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>someNumber<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>someNumber<span style="color: #000066; font-weight: bold;">,</span> density<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> isSensor<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
sim<span style="color: #000066; font-weight: bold;">.</span>addCircle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>someNumber<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>someNumber<span style="color: #000066; font-weight: bold;">,</span> radius<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>someNumber<span style="color: #000066; font-weight: bold;">,</span> density<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> isSensor<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://thecoho.net/2010/06/14/simple-quickbox2d-sensors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix for papervision 3ds parser</title>
		<link>http://thecoho.net/2009/04/09/fix-for-papervision-3ds-parser/</link>
		<comments>http://thecoho.net/2009/04/09/fix-for-papervision-3ds-parser/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 15:58:56 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[code stuffs]]></category>
		<category><![CDATA[physical stuffs]]></category>

		<guid isPermaLink="false">http://thecoho.net/?p=41</guid>
		<description><![CDATA[If you are having problems with the 3ds parser in papervision &#38; you are using CS4 this might help you.
download here
To use it, just unzip the parsers.zip and copy everything over in your papervision3d/objects/parsers folder. It&#8217;ll replace some files, this should be ok, and it&#8217;ll add one with some helper files.
CONTEXT (since code will change [...]]]></description>
			<content:encoded><![CDATA[<p>If you are having problems with the 3ds parser in papervision &amp; you are using CS4 this might help you.</p>
<p><a href="http://thecoho.net/parsers.zip">download here</a></p>
<p>To use it, just unzip the parsers.zip and copy everything over in your papervision3d/objects/parsers folder. It&#8217;ll replace some files, this should be ok, and it&#8217;ll add one with some helper files.</p>
<p>CONTEXT (since code will change and, hopefully, this will be made useless soon by the papervision guys)<span id="more-41"></span></p>
<p>I have been using the 3ds parser without problem in CS3 for months. I&#8217;ve recently started using it in FLARTOOLKIT experiments, again with no problem. I then switched to FLARmanager, which required both CS4 and a recent papervision (i&#8217;ve been using an older one). My 3ds imports broke, even test code I downloaded broke. I updated to the latest papervision (INFO: Papervision3D Public Beta 2.0 &#8211; Great White (December 3rd, 2008)) and it was still broke, and then I went back and reintegrated everything with new papervision and CS3 &#8211; no problems. So CS4 does something weird.</p>
<p>A solution (which Josh L posted in a comment at <a href="http://drawlogic.com/2008/04/11/3ds-parser-added-to-papervision-from-away3d/comment-page-1/">drawlogic</a>) was suggested and I followed it. Thanks for the advice! Considering I had never made custom classes before and had a few little issues doing it, I zipped up the solution for everything to share.</p>
<p><a href="http://thecoho.net/parsers.zip">download here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://thecoho.net/2009/04/09/fix-for-papervision-3ds-parser/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
