<?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>Emanuele Feronato</title>
	<atom:link href="http://www.emanueleferonato.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emanueleferonato.com</link>
	<description>italian geek and PROgrammer</description>
	<lastBuildDate>Thu, 11 Mar 2010 00:11:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Get up to $100,000 for your next Flash game with Mochi GAME Developer Fund</title>
		<link>http://www.emanueleferonato.com/2010/03/11/get-up-to-to-100000-for-your-next-flash-game-with-mochi-game-developer-fund/</link>
		<comments>http://www.emanueleferonato.com/2010/03/11/get-up-to-to-100000-for-your-next-flash-game-with-mochi-game-developer-fund/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 23:30:32 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Monetize]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2519</guid>
		<description><![CDATA[Imagine a Flash game sponsor encouraging you to use MochiAds, helping you to market and promote your game, reviewing and testing it putting his experience at your service and helping you to integrate the latest APIs in the most proficuous way.
For some developers this dream could become true because MochiMedia created the Mochi GAME Developer [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine a Flash game sponsor encouraging you to use <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiAds</a>, helping you to market and promote your game, reviewing and testing it putting his experience at your service and helping you to integrate the latest APIs in the most proficuous way.</p>
<p>For some developers this dream could become true because <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiMedia</a> created the <strong>Mochi GAME Developer Fund</strong>: a $10 million fund that will help promising Flash and social game developers support their games through sponsorship, licensing and publishing deals.</p>
<p>The fund will assist small Flash game development studios and independent game developers worldwide in building world-class games and businesses.</p>
<p><a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank"><img src="/wp-content/uploads/2010/03/mochi-dev-fund-logo-300x198.png" /></a></p>
<p>You will find the details in the <a href="http://www.mochimedia.com/developers/fund.html" target = "_blank">official page</a>, with some FAQs. Here&#8217;s the four more interesting:</p>
<p><strong>Q: What is the Mochi GAME Developer Fund?</strong><br />
A: The Mochi GAME Developer Fund $10 million USD fund for investing in promising Flash and social game developers through sponsorship, licensing, and publishing. The goal of the Fund is to assist developers in launching and building rockstar premium games on the Mochi platform, and to cultivate long term relationships with Flash and social game developers looking to build world-class games and businesses. </p>
<p><strong>Q: What is the target deal size for the Mochi GAME Developer Fund?</strong><br />
A: The Mochi GAME Developer Fund intends to partner with Flash and social game developers on a sponsorship, licensing or publishing basis anywhere from $1,000 to $100,000. Additional consideration may be given to other types of relationships on a case-by-case basis. Generally, the funds will be given upon the achievement of certain milestones of the game development process. The specific milestones can be discussed with the Mochi GAME Developer Fund team. </p>
<p><strong>Q: What types of games is the Mochi GAME Developer Fund seeking?</strong><br />
A: We are open to Flash and social games of all genres and gameplay types targeting all kinds of audiences. Particular attention will be given to games that have high potential to monetize via MochiCoins microtransactions, include social elements that may be enhanced via MochiSocial or are particularly great games. </p>
<p><strong>Q: I don’t live in the United States. Can I still work with the Mochi GAME Developer Fund?</strong><br />
A: Absolutely! Flash and social game developers are located all across the world. We care less about where you live and care more about helping you build great games using the Mochi platform. </p>
<p>According to these FAQs, it looks like an exclusive sponsorship, but I hope to give you more information as I&#8217;m running to <a href="http://mochimedia.us1.list-manage.com/subscribe?u=1c2da7d6e8&#038;id=7ce02a64fb" target = "_blank">submit the form</a> and ask for some millions for my next game.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/03/11/get-up-to-to-100000-for-your-next-flash-game-with-mochi-game-developer-fund/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Create a dynamic content animated footer ad for your site in just 9 jQuery lines &#8211; 17 lines version</title>
		<link>http://www.emanueleferonato.com/2010/03/10/create-a-dynamic-content-animated-footer-ad-for-your-site-in-just-9-jquery-lines-17-lines-version/</link>
		<comments>http://www.emanueleferonato.com/2010/03/10/create-a-dynamic-content-animated-footer-ad-for-your-site-in-just-9-jquery-lines-17-lines-version/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 17:35:09 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2510</guid>
		<description><![CDATA[Some days ago I showed you how to create a dynamic content animated footer ad for your site in just 9 jQuery lines.
Now it&#8217;s time to write eight more lines to add two important features:
The first, as suggested in a comment, is allowing to set a delay before the ad appears.
The second is using a [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago I showed you how to <a href="http://www.emanueleferonato.com/2010/03/03/create-a-dynamic-content-animated-footer-ad-for-your-site-in-just-15-jquery-lines/">create a dynamic content animated footer ad for your site in just 9 jQuery lines</a>.</p>
<p>Now it&#8217;s time to write eight more lines to add two important features:</p>
<p>The first, as suggested in a comment, is allowing to set a delay before the ad appears.</p>
<p>The second is using a cookie to let the ad appear only once in a session. This means if you refresh the page, the ad won&#8217;t appear again, until you close the browser window and open it again.</p>
<p><a href="http://www.emanueleferonato.com/stuff/triqui_ad/index2.html" target = "_blank">This is what we&#8217;ll get</a>&#8230; the ad appears after three seconds, and only once in a session.</p>
<p>Now let&#8217;s see the new lines added:<span id="more-2510"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$.<span style="color: #660066;">delay</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>time<span style="color: #339933;">,</span>ret_function<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> ret <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>timer<span style="color: #339933;">:</span>setTimeout<span style="color: #009900;">&#40;</span>ret_function<span style="color: #339933;">,</span>time<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> ret<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> delayed_start <span style="color: #339933;">=</span> <span style="color: #CC0000;">3000</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> path_to_dynamic_file <span style="color: #339933;">=</span> <span style="color: #3366CC;">'ajax.php'</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">cookie</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;triqui_ad&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		document.<span style="color: #660066;">cookie</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;triqui_ad=1&quot;</span><span style="color: #339933;">;</span>
		$.<span style="color: #660066;">ajaxSetup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>cache<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_ad'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">wrap</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div id=&quot;triqui_container&quot;&gt;&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> delayed_start <span style="color: #339933;">=</span> $.<span style="color: #660066;">delay</span><span style="color: #009900;">&#40;</span>delayed_start<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_ad'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span>path_to_dynamic_file<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_ad'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'display'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'block'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_ad'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' &amp;bull; &lt;a id=&quot;triqui_ad_close&quot;&gt;Close&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_ad_close'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		   			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		  		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>Lines 3-6</strong>: Declaring a new jQuery function called <code>delay</code>, that&#8217;s just a callback after a given amount of milliseconds. </p>
<p><strong>Line 8</strong>: Variable storing the number of milliseconds to wait before showing the ad</p>
<p><strong>Line 9</strong>: Variable storing the path to the dynamic file</p>
<p><strong>Line 10</strong>: Checking if I have a cookie called <code>triqui_ad</code>. The statement is true if I don&#8217;t have it.</p>
<p><strong>Line 11</strong>: Creating a cookie called <code>triqui_ad</code>. Since there is not an expiration date, it will expire when the user will close the browser.</p>
<p><strong>Line 14</strong>: The entire function explained in <a href="http://www.emanueleferonato.com/2010/03/03/create-a-dynamic-content-animated-footer-ad-for-your-site-in-just-15-jquery-lines/">part 1</a> is executed only after the preset delay.</p>
<p>And that&#8217;s it&#8230; any idea for additional features?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/03/10/create-a-dynamic-content-animated-footer-ad-for-your-site-in-just-9-jquery-lines-17-lines-version/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sell sitelocked version of your Flash games and even .fla sources to Free Online Games</title>
		<link>http://www.emanueleferonato.com/2010/03/09/sell-sitelocked-version-of-your-flash-games-and-even-fla-sources-to-free-online-games/</link>
		<comments>http://www.emanueleferonato.com/2010/03/09/sell-sitelocked-version-of-your-flash-games-and-even-fla-sources-to-free-online-games/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 09:28:23 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Monetize]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2500</guid>
		<description><![CDATA[Are you looking for a quick way to sell a site locked version of your game? Do you want to earn some more selling the .fla source code? Then Neil from Free Online Games (aka FOG) is your man.

FOG is looking for any game, no matter how old it is or how wide spread it [...]]]></description>
			<content:encoded><![CDATA[<p>Are you looking for a quick way to sell a site locked version of your game? Do you want to earn some more selling the <code>.fla</code> source code? Then <strong>Neil</strong> from <a href="http://www.freeonlinegames.com/" target = "_blank">Free Online Games</a> (aka FOG) is your man.</p>
<p><a href="http://www.freeonlinegames.com/" target = "_blank"><img src="/wp-content/uploads/2010/03/fog.jpg" /></a></p>
<p>FOG is looking for any game, no matter how old it is or how wide spread it is already, as long as it&#8217;s a decent game. In this case FOG will buy you a site locked version of your game, or even the <code>.fla</code> source code.</p>
<p><strong>What happens when <a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a> buys a site locked version of your game</strong></p>
<p>* The game is sitelocked to <a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a><br />
* You have to interface your game with their API<br />
* You have to remove all external branding and ads</p>
<p><strong>What happens when <a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a> buys the source code of your game</strong></p>
<p>* <a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a> retains the rights to re-release, resell, re-use, delete, make more version and all in all everything with your code<br />
* All branding, ads and credits will be removed</p>
<p>Note: if your game is already sponsored, you may no longer have the right to sell your source code. Check with your sponsor as <a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a> is not responsible for your previous deals<span id="more-2500"></span></p>
<p><strong>My experience</strong></p>
<p>I am currently managing the latest small details about <a href="http://www.emanueleferonato.com/2009/12/09/play-barbalance-my-latest-game/">BarBalance</a>. I&#8217;m selling the source code. Working with Neil is a pleasure as he&#8217;s very kind, professional and will support you through the entire process. Just consider FOG&#8217;s HQ is located in United Kingdom when your plan to chat with him.</p>
<p>His email, as well as his Skype, Messenger, ICQ, Yahoo and GTalk ids is Neil[at]FOG[dot]COM</p>
<p>I asked him a couple of questions just to give you as much information as possible</p>
<p><strong>Are you really buying ANY kind of game <code>.fla</code>s?</strong></p>
<p>I primarily buy site locks of games, however if the source is available then we do try and purchase that too. I&#8217;m not out to purchase things left right and centre, all the games that are offered we review meticulously to see if it meets our standards, and at the moment, the majority of submissions are being rejected.</p>
<p><strong>What&#8217;s the meaning of buying source codes? Don&#8217;t you think in most cases the sources would be hard to understand (i.e variable names in foreign languages, no optimization and so on&#8230;)</strong></p>
<p>Sources in other languages aren&#8217;t too much of a concern as we have a multilingual staff base here at fog, if the code is not optimised then our in house programmer will go over it and see what can be done</p>
<p><strong>Do you already have an example of a bought and republished game?</strong></p>
<p>We have plenty of site locked games on our site. for games that we have bought source codes of and redone as fog games, and our own developed games can be seen at <a href="http://www.freegamesforyourwebsite.com/" target ="_blank">www.freegamesforyourwebsite.com</a></p>
<p>a few examples of site locks are</p>
<p><a href="http://www.freeonlinegames.com/rpg-games/pizza-pronto.html" target = "_blank">Pizza Pronto</a><br />
<a href="http://www.freeonlinegames.com/adventure-games/tank-in-action.html" target = "_blank">Tank In Action</a><br />
<a href="http://www.freeonlinegames.com/racing-games/mountain-rescue-driver.html" target = "_blank">Mountain Rescue Driver</a><br />
<a href="http://www.freeonlinegames.com/puzzle-games/perfect-balance-2.html" target = "_blank">Perfect Balance 2</a></p>
<p><strong>How much can a developer earn from <a href="<a href="http://www.freeonlinegames.com/" target = "_blank">FOG</a>?</strong></p>
<p>Generally prices range from $100-$500 for site locks, source code can be anything from $100-$1000 or more depending on the quality&#8230; I don&#8217;t feel that there is a limit on what a developer can earn for a<br />
decent game, if it is really that good and someone wants it they&#8217;ll lay the money on the table to get it.</p>
<p>Hope this will help you to further monetize your games.</p>
<p><strong>** edit **</strong></p>
<p><a href="http://www.emanueleferonato.com/2009/12/09/play-barbalance-my-latest-game/">BarBalance</a> source code sold :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/03/09/sell-sitelocked-version-of-your-flash-games-and-even-fla-sources-to-free-online-games/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Protect your work from ActionScript code theft with SWF Protector</title>
		<link>http://www.emanueleferonato.com/2010/03/05/protect-your-work-from-actionscript-code-theft-with-swf-protector/</link>
		<comments>http://www.emanueleferonato.com/2010/03/05/protect-your-work-from-actionscript-code-theft-with-swf-protector/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 10:03:32 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 2]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2480</guid>
		<description><![CDATA[&#171; I&#8217;ve just found a site that won a top international online advertising award &#8211; and it&#8217;s been blatantly lifted from me!
Its a flash application that has the same vectors and almost certainly the same AS code. Is there anything I can do? I&#8217;m in the UK &#8211; they&#8217;re in Brazil. &#187;
The guy who opened [...]]]></description>
			<content:encoded><![CDATA[<p>&laquo; I&#8217;ve just found a site that won a top international online advertising award &#8211; and it&#8217;s been blatantly lifted from me!</p>
<p>Its a flash application that has the same vectors and <strong>almost certainly the same AS code</strong>. Is there anything I can do? I&#8217;m in the UK &#8211; they&#8217;re in Brazil. &raquo;</p>
<p>The guy who opened <a href="http://www.webmasterworld.com/webmaster/3033990.htm" target = "_blank">this thread</a> looks quite desperate&#8230; now imagine this happening to your latest Flash game.</p>
<p>That&#8217;s why you <strong>must</strong> protect your code. You don&#8217;t want someone else stealing your work.</p>
<p>I am going to review <a href="http://www.dcomsoft.com/" target = "_blank">DCOM Soft</a>&#8217;s SWF Protector.</p>
<p><a href="http://www.dcomsoft.com/" target = "_blank"><img src="/wp-content/uploads/2010/03/swfpro01.jpg" /></a></p>
<p><strong>SWF Protector</strong></p>
<p><a href="http://www.dcomsoft.com/" target = "_blank">SWF Protector</a> is an swf protector software working through actionscript encryption to secure your actionscript content. This means decompilers won&#8217;t be able to read your actionscript.<span id="more-2480"></span></p>
<p>The most interesting <a href="http://www.dcomsoft.com/" target = "_blank">SWF Protector</a> features are:</p>
<p>* Inexpensive: only $59.95 for a Business License. <a href="http://www.emanueleferonato.com/2009/12/07/milestone-reached-100-with-mochiads/">You can earn twice in just one day with a single game</a>.</p>
<p>* Simple and fast. You can encrypt your SWF with a couple of clicks.</p>
<p>* Cross-platform. Available for Windows, Mac and Linux.</p>
<p>* Mass protection. You can protect several SWFs at once.</p>
<p>This is the interface you&#8217;ll see when you are about to secure your flash content: </p>
<p><img src="/wp-content/uploads/2010/03/swfpro02.jpg" /></p>
<p>I am testing the software on the file created on <a href="http://www.emanueleferonato.com/2010/02/25/box2d-flash-game-creation-tutorial-part-2/">Box2D Flash game creation tutorial – part 2</a> tutorial.</p>
<p>This is the original content of the <code>custom_contact_listener.as</code> file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.Shapes.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.Joints.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.Contacts.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #004993;">Math</span>.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #9900cc; font-weight: bold;">class</span> custom_contact_listener extends b2ContactListener <span style="color: #000000;">&#123;</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> BeginContact<span style="color: #000000;">&#40;</span>contact<span style="color: #000000; font-weight: bold;">:</span>b2Contact<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// getting the fixtures that collided</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> fixtureA<span style="color: #000000; font-weight: bold;">:</span>b2Fixture=contact.GetFixtureA<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> fixtureB<span style="color: #000000; font-weight: bold;">:</span>b2Fixture=contact.GetFixtureB<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// if the fixture is a sensor, mark the parent body to be removed</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>fixtureB.IsSensor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				fixtureB.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>fixtureA.IsSensor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				fixtureA.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Now, I will use a Flash decompiler to extract the same file from an unprotected version of the swf&#8230; here it is:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900;">//class custom_contact_listener</span>
<span style="color: #9900cc; font-weight: bold;">package</span> 
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
    <span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.Contacts.<span style="color: #000000; font-weight: bold;">*</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">internal</span> <span style="color: #9900cc; font-weight: bold;">class</span> custom_contact_listener extends Box2D.Dynamics.b2ContactListener
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> custom_contact_listener<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #0033ff; font-weight: bold;">return</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> override <span style="color: #339966; font-weight: bold;">function</span> BeginContact<span style="color: #000000;">&#40;</span>arg1<span style="color: #000000; font-weight: bold;">:</span>Box2D.Dynamics.Contacts.b2Contact<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #6699cc; font-weight: bold;">var</span> loc1<span style="color: #000000; font-weight: bold;">:*</span>=arg1.GetFixtureA<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #6699cc; font-weight: bold;">var</span> loc2<span style="color: #000000; font-weight: bold;">:*</span>=arg1.GetFixtureB<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>loc2.IsSensor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> 
            <span style="color: #000000;">&#123;</span>
                loc2.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>loc1.IsSensor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> 
            <span style="color: #000000;">&#123;</span>
                loc1.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">return</span>;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>The code is amost more polished&#8230; and obviously it works.</p>
<p>Now let&#8217;s try to do the same on the obfuscated swf made by <a href="http://www.dcomsoft.com/" target = "_blank">SWF Protector</a>&#8230; that&#8217;s what I got (sorry for the italian screenshot: I&#8217;m currently running an italian version of Windows7)</p>
<p><img src="/wp-content/uploads/2010/03/swfpro03.jpg" /></p>
<p>The decompiler crashed&#8230; probably the amount of weird characters inserted by the flash obfuscator made it crash.</p>
<p>In the end, <a href="http://www.dcomsoft.com/" target = "_blank">SWF Protector</a> is simple to use and very fast. It has shown lightning-fast speeds of SWF files loading, processing and saving and uses four reliable protection algorithms.</p>
<p>You can download a trial version on the official site or <strong>win one of three business licenses</strong> I am giving away being the first to reply &#8220;I want one&#8221; when this post will be published on my <a href="http://www.facebook.com/pages/Emanuele-Feronato/50374255154">Facebook Fanpage</a>. This is a special giveaway for three of my Facebook fans. And won&#8217;t be the only one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/03/05/protect-your-work-from-actionscript-code-theft-with-swf-protector/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Create a dynamic content animated footer ad for your site in just 9 jQuery lines</title>
		<link>http://www.emanueleferonato.com/2010/03/03/create-a-dynamic-content-animated-footer-ad-for-your-site-in-just-15-jquery-lines/</link>
		<comments>http://www.emanueleferonato.com/2010/03/03/create-a-dynamic-content-animated-footer-ad-for-your-site-in-just-15-jquery-lines/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 21:50:49 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2460</guid>
		<description><![CDATA[Have you ever seen those ads sliding up from the bottom of your page when you are visiting a website? We are going to create a simple one in just 9 jQuery lines.
Moreover, with this script you will need to add just one line to your site to display the ad.
Just to make it easier [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever seen those ads sliding up from the bottom of your page when you are visiting a website? We are going to create a simple one in just 9 <a href="http://jquery.com/" target  "_blank">jQuery</a> lines.</p>
<p>Moreover, with this script you will need to add just one line to your site to display the ad.</p>
<p>Just to make it easier to understand, I am showing you for free the principles some &#8220;companies&#8221; <a href="http://www.google.com/webhp?hl=en#hl=en&#038;source=hp&#038;q=footer+ad&#038;rlz=1R2GZAZ_enIT351&#038;aq=f&#038;aqi=g10&#038;aql=&#038;oq=&#038;fp=f15a301262521d7" target = "_blank">sell at more than $40</a>. According to such sites, ads like the one we are about to make should increase your conversions, have more readers sign up to your newsletter, and make you live in harmony. All in one-</p>
<p>Unfortunately, I am only showing you how to create such ad in a bunch of jQuery lines.</p>
<p>This is what we are going to make: <a href="http://www.emanueleferonato.com/stuff/triqui_ad/" target = "_blank">Watch the example</a>.</p>
<p>Ready for the recipe? Here we go:</p>
<p><strong>A web page</strong></p>
<p>Obviously, you need a webpage. Any webpage will fit, as long as you include</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;triqui_ad&quot;&gt;&lt;/div&gt;</pre></div></div>

<p>just before the <code>&lt;/body&gt;</code> tag.</p>
<p><strong>jQuery</strong></p>
<p>Then it&#8217;s time to add the power of jQuery to the page: insert this script between <code>&lt;head&gt;</code> and <code>&lt;/head&gt;</code><span id="more-2460"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$.<span style="color: #660066;">ajaxSetup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>cache<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_ad'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">wrap</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div id=&quot;triqui_container&quot;&gt;&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_ad'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ajax.php'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_ad'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'display'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'block'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_ad'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' &amp;bull; &lt;a id=&quot;triqui_ad_close&quot;&gt;Close&lt;/a&gt; '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_ad_close'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
   			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#triqui_container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
  		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>Line 1</strong>: loading the latest jQuery version. I am loading it directly from Google to get the latest stable version with no stress for my server.</p>
<p><strong>Line 3</strong>: Function to be executed when the document DOM is fully loaded.</p>
<p><strong>Line 4</strong>: Disabling the cache when using Ajax calls. That&#8217;s why when you reload the page in the <a href="http://www.emanueleferonato.com/stuff/triqui_ad/" target = "_blank">example</a>, you always get the current timestamp</p>
<p><strong>Line 5</strong>: I had to add this line because I wanted the final user to type in as less code as possible, so at the moment you just have to add</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;triqui_ad&quot;&gt;&lt;/div&gt;</pre></div></div>

<p>while the &#8220;real&#8221; code should be</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id = &quot;triqui_container&quot;&gt;&lt;div id=&quot;triqui_ad&quot;&gt;&lt;/div&gt;&lt;/div&gt;</pre></div></div>

<p>Using <code>wrap</code> you will (guess what?) wrap an HTML structure around the selected element.</p>
<p><strong>Line 6</strong>: This is the most important line. I am loading the result of the Ajax call made on the <code>ajax.php</code> file. This means I am printing inside the <code>div</code> everything <code>ajax.php</code> will echo. In my case, it will print the current date since this is the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello, I am a dynamic content created on &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'l jS \of F Y h:i:s A'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>As you can imagine, <code>load</code> loads data from the server and place the returned HTML into the matched element. The only issue is it caches the result, that&#8217;s why I disabled it at <strong>line 4</strong></p>
<p><strong>Line 7</strong>: Here I am showing the content of the div containing the ad. When you&#8217;ll look at the css, you&#8217;ll find there was a <code>display:none</code> to keep it hidden until the script is ready to work.</p>
<p><strong>Line 8</strong>: Time to slide in the ad</p>
<p><strong>Line 9</strong>: Appending a link to close the ad</p>
<p><strong>Line 10</strong>: Triggering the link used to close the ad</p>
<p><strong>Line 11</strong>: Sliding away the ad when the user clicks on the link</p>
<p><strong>CSS</strong></p>
<p>And finally it&#8217;s time to stylize the ad.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#triqui_container</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">fixed</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#triqui_ad</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#e5e5e5</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#triqui_ad_close</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>You can custom the stylesheet as you want as long as you set <code>display:none</code> to the ad and <code>position:fixed</code> and <code>bottom:0</code> to the container.</p>
<p>Have fun&#8230; would you like more options?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/03/03/create-a-dynamic-content-animated-footer-ad-for-your-site-in-just-15-jquery-lines/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Understanding Box2D&#8217;s one-way platforms, aka CLOUDS</title>
		<link>http://www.emanueleferonato.com/2010/03/02/understanding-box2ds-one-way-platforms-aka-clouds/</link>
		<comments>http://www.emanueleferonato.com/2010/03/02/understanding-box2ds-one-way-platforms-aka-clouds/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 23:24:20 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Box2D]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2448</guid>
		<description><![CDATA[One of the new features introduced with Box2D 2.1a is the improved contact listener class which comes in hand when we want to create one-way platforms, or &#8220;clouds&#8221;.
This can be made thanks to a function called before the contact is processed&#8230; something like &#8220;hey, two bodies are about to collide, what should I do?&#8221;&#8230; so [...]]]></description>
			<content:encoded><![CDATA[<p>One of the new features introduced with <a href="http://www.emanueleferonato.com/2010/01/27/box2dflash-2-1a-released-what-changed/">Box2D 2.1a</a> is the improved contact listener class which comes in hand when we want to create one-way platforms, or &#8220;clouds&#8221;.</p>
<p>This can be made thanks to a function called <strong>before</strong> the contact is processed&#8230; something like &#8220;hey, two bodies are about to collide, what should I do?&#8221;&#8230; so you can decide to disable the contact for every collision you want.</p>
<p>The function used to do this task is <code>PreSolve</code>, working for all awake bodies that aren&#8217;t sensors.</p>
<p>If you don&#8217;t know what is a Box2D sensor, check <a href="http://www.emanueleferonato.com/2010/02/25/box2d-flash-game-creation-tutorial-part-2/">Box2D Flash game creation tutorial – part 2</a>.</p>
<p>So the concept is: listen for collisions, if a collision involves the cloud wall and the player, then check if the player is higher or lower than the cloud. If it&#8217;s lower, don&#8217;t process the collision and let the player fly through the cloud.</p>
<p>Let&#8217;s see the script, directly taken from <a href="http://www.emanueleferonato.com/2010/02/25/box2d-flash-game-creation-tutorial-part-2/">Box2D Flash game creation tutorial – part 2</a>:<span id="more-2448"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">KeyboardEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.Shapes.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #004993;">Math</span>.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ball02 extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #009900;">// world creation</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> world<span style="color: #000000; font-weight: bold;">:</span>b2World=<span style="color: #0033ff; font-weight: bold;">new</span> b2World<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">10.0</span><span style="color: #000000;">&#41;</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> world_scale<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">30</span>;
		<span style="color: #009900;">// the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> player<span style="color: #000000; font-weight: bold;">:</span>b2Body;
		<span style="color: #009900;">// force to apply to the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> force<span style="color: #000000; font-weight: bold;">:</span>b2Vec2;
		<span style="color: #009900;">// variables to store whether the keys are pressed or not</span>
		<span style="color: #009900;">// true = pressed;</span>
		<span style="color: #009900;">// false = unpressed</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">left</span>,<span style="color: #004993;">right</span>,up,down<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
		<span style="color: #009900;">// declaring my custom contact listener class</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> contact_listener=<span style="color: #0033ff; font-weight: bold;">new</span> custom_contact_listener<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ball02<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// assigning the contact listener to the world</span>
			world.SetContactListener<span style="color: #000000;">&#40;</span>contact_listener<span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// calling debug draw function</span>
			debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// drawing the boundaries</span>
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;ground&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">200</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;left&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">200</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;right&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;roof&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">200</span>,<span style="color: #000000; font-weight:bold;">300</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;middle&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// adding the player at 250,200</span>
			add_player<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">350</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// adding some coins</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">1</span>; i<span style="color: #000000; font-weight: bold;">&lt;</span>=<span style="color: #000000; font-weight:bold;">5</span>; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				draw_coin<span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">50</span>,<span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">150</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">25</span>,<span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900;">// listeners needed for the game to work</span>
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>, update<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">KeyboardEvent</span>.<span style="color: #004993;">KEY_DOWN</span>,on_key_down<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">KeyboardEvent</span>.<span style="color: #004993;">KEY_UP</span>,on_key_up<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// according to the key pressed, set the proper variable to &quot;true&quot;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> on_key_down<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">keyCode</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">37</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">left</span>=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">38</span> <span style="color: #000000; font-weight: bold;">:</span>
					up=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">39</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">right</span>=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">40</span> <span style="color: #000000; font-weight: bold;">:</span>
					down=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// according to the key released, set the proper variable to &quot;false&quot;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> on_key_up<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">keyCode</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">37</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">left</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">38</span> <span style="color: #000000; font-weight: bold;">:</span>
					up=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">39</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">right</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">40</span> <span style="color: #000000; font-weight: bold;">:</span>
					down=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function to draw a coin</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> draw_coin<span style="color: #000000;">&#40;</span>px,py,r<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_circle<span style="color: #000000; font-weight: bold;">:</span>b2CircleShape=<span style="color: #0033ff; font-weight: bold;">new</span> b2CircleShape<span style="color: #000000;">&#40;</span>r<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_circle;
			<span style="color: #009900;">// look! it's a sensor!!</span>
			my_fixture.isSensor=<span style="color: #0033ff; font-weight: bold;">true</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> world_body<span style="color: #000000; font-weight: bold;">:</span>b2Body=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			world_body.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// simple function to draw a box</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> draw_box<span style="color: #000000;">&#40;</span>px,py,w,h,<span style="color: #004993;">d</span>,ud<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">d</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				my_body.<span style="color: #004993;">type</span>=b2Body.b2_dynamicBody;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_box<span style="color: #000000; font-weight: bold;">:</span>b2PolygonShape = <span style="color: #0033ff; font-weight: bold;">new</span> b2PolygonShape<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_box.SetAsBox<span style="color: #000000;">&#40;</span>w<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">/</span>world_scale, h<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_box;
			<span style="color: #6699cc; font-weight: bold;">var</span> world_body<span style="color: #000000; font-weight: bold;">:</span>b2Body=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			world_body.SetUserData<span style="color: #000000;">&#40;</span>ud<span style="color: #000000;">&#41;</span>;
			world_body.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function to add the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> add_player<span style="color: #000000;">&#40;</span>px,py<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">type</span>=b2Body.b2_dynamicBody;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_circle<span style="color: #000000; font-weight: bold;">:</span>b2CircleShape=<span style="color: #0033ff; font-weight: bold;">new</span> b2CircleShape<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_circle;
			player=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			player.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;player&quot;</span><span style="color: #000000;">&#41;</span>;
			player.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// debug draw</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> debug_draw<span style="color: #000000; font-weight: bold;">:</span>b2DebugDraw = <span style="color: #0033ff; font-weight: bold;">new</span> b2DebugDraw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> debug_sprite<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>debug_sprite<span style="color: #000000;">&#41;</span>;
			debug_draw.SetSprite<span style="color: #000000;">&#40;</span>debug_sprite<span style="color: #000000;">&#41;</span>;
			debug_draw.SetDrawScale<span style="color: #000000;">&#40;</span>world_scale<span style="color: #000000;">&#41;</span>;
			debug_draw.SetFlags<span style="color: #000000;">&#40;</span>b2DebugDraw.e_shapeBit<span style="color: #000000;">&#41;</span>;
			world.SetDebugDraw<span style="color: #000000;">&#40;</span>debug_draw<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function to be executed at every frame</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// setting the force to null</span>
			force=<span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// according to the key(s) pressed, add the proper vector force</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">left</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">right</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>up<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>down<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900;">// if there is any force, then apply it</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>force.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">||</span>force.<span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				player.ApplyForce<span style="color: #000000;">&#40;</span>force,player.GetWorldCenter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			world.Step<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
			world.ClearForces<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// scanning through all bodies</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> worldbody<span style="color: #000000; font-weight: bold;">:</span>b2Body = world.GetBodyList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; worldbody; worldbody = worldbody.GetNext<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">// if a body is marked as &quot;remove&quot;...</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>worldbody.GetUserData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>==<span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #009900;">// ... just remove it!!</span>
					world.DestroyBody<span style="color: #000000;">&#40;</span>worldbody<span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
			world.DrawDebugData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><strong>Line 34</strong>: with the old function introduced at <a href="http://www.emanueleferonato.com/2010/02/16/understanding-box2d-applicable-forces/">Understanding Box2D applicable forces</a> I create a box marked as &#8220;middle&#8221;.</p>
<p>No other changes on the main file, now let&#8217;s see the <code>custom_contact_listener.as</code> file</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.Shapes.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.Joints.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.Contacts.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #004993;">Math</span>.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #9900cc; font-weight: bold;">class</span> custom_contact_listener extends b2ContactListener <span style="color: #000000;">&#123;</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> BeginContact<span style="color: #000000;">&#40;</span>contact<span style="color: #000000; font-weight: bold;">:</span>b2Contact<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// getting the fixtures that collided</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> fixtureA<span style="color: #000000; font-weight: bold;">:</span>b2Fixture=contact.GetFixtureA<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> fixtureB<span style="color: #000000; font-weight: bold;">:</span>b2Fixture=contact.GetFixtureB<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// if the fixture is a sensor, mark the parent body to be removed</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>fixtureB.IsSensor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				fixtureB.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>fixtureA.IsSensor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				fixtureA.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> PreSolve<span style="color: #000000;">&#40;</span>contact<span style="color: #000000; font-weight: bold;">:</span>b2Contact, oldManifold<span style="color: #000000; font-weight: bold;">:</span>b2Manifold<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// getting the fixtures that collided</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> fixtureA<span style="color: #000000; font-weight: bold;">:</span>b2Fixture=contact.GetFixtureA<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> fixtureB<span style="color: #000000; font-weight: bold;">:</span>b2Fixture=contact.GetFixtureB<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// variable to handle bodies y position</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> player_y_position<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> platform_y_position<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>;
			<span style="color: #009900;">// checking if the collision bodies are the ones marked as &quot;middle&quot; and &quot;player&quot;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>fixtureA.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.GetUserData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>==<span style="color: #990000;">&quot;middle&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> fixtureB.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.GetUserData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>==<span style="color: #990000;">&quot;player&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">||</span><span style="color: #000000;">&#40;</span>fixtureA.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.GetUserData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>==<span style="color: #990000;">&quot;player&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> fixtureB.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.GetUserData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>==<span style="color: #990000;">&quot;middle&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">// determining if the fixtureA represents the platform (&quot;middle&quot;) or the player</span>
				<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>fixtureA.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.GetUserData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">&quot;middle&quot;</span> <span style="color: #000000; font-weight: bold;">:</span>
						<span style="color: #009900;">// determining y positions</span>
						player_y_position=fixtureB.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.GetPosition<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">30</span>;
						platform_y_position=fixtureA.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.GetPosition<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">30</span>;
						<span style="color: #0033ff; font-weight: bold;">break</span>;
					<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">&quot;player&quot;</span> <span style="color: #000000; font-weight: bold;">:</span>
						<span style="color: #009900;">// determining y positions</span>
						player_y_position=fixtureA.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.GetPosition<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">30</span>;
						platform_y_position=fixtureB.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.GetPosition<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">30</span>;
<span style="color: #000000; font-weight: bold;">&lt;</span>strong<span style="color: #000000; font-weight: bold;">&gt;</span>						<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #000000;">&#125;</span>
				<span style="color: #009900;">// checking distance between bodies</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">distance</span> = player_y_position<span style="color: #000000; font-weight: bold;">-</span>platform_y_position;
				<span style="color: #009900;">// if the distance is greater than player radius + half of the platform height...</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>distance<span style="color: #000000; font-weight: bold;">&gt;-</span><span style="color: #000000; font-weight:bold;">14.5</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #009900;">// don't manage the contact</span>
					contact.SetEnabled<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><strong>Line 22</strong>: beginning of the PreSolve function, the core of this example</p>
<p><strong>Lines 24-25</strong>: getting the fixtures that generated the contact</p>
<p><strong>Lines 27-28</strong>: declaring two variables to store y position of both bodies</p>
<p><strong>Line 30</strong>: here I am checking if the fixtures are the one associated to the player and the one associated to the cloud</p>
<p><strong>Lines 32-43</strong>: according to the fixture associated to the player and the one associated to the cloud, I am saving in the variables declared at <strong>lines 27-28</strong> the y position of both bodies. I am multiplying directly by <code>30</code> without passing the right <code>world_scale</code> value declared at <strong>line 13</strong> of the main class because it&#8217;s not the purpose of this tutorial.</p>
<p><strong>Line 45</strong>: Determining the vertical distance from the player and the cloud</p>
<p><strong>Lines 47-50</strong>: If the player is not at least <code>14.5</code> pixels higher than the cloud, then disable the contact. Why <code>14.5</code>? It&#8217;s the sum of the ball radius (10) and half the cloud height (5)&#8230; and I am not using <code>15</code> because I found sometimes the distance when the ball falls on the cloud is <code>14.93</code>, so the cloud won&#8217;t &#8220;hold&#8221; the ball, letting it fall down. With <code>14.5</code>, I am sure this won&#8217;t happen.</p>
<p>And this is the result&#8230; </p>
<p><embed src="/wp-content/uploads/2010/03/oneway.swf" allowscriptaccess="always" menu="false" quality="high" width="500" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
<p>Move the ball by tapping arrow keys and watch the static object in the center of the stage act as a cloud&#8230; you can fly through it from bottom to top, but you can&#8217;t do it from top to bottom.</p>
<p><a href="/wp-content/uploads/2010/03/oneway.zip">Download the source code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/03/02/understanding-box2ds-one-way-platforms-aka-clouds/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Triqui MochiAds Arcade plugin for WordPress upgraded to 1.2</title>
		<link>http://www.emanueleferonato.com/2010/02/26/triqui-mochiads-arcade-plugin-for-wordpress-upgraded-to-1-2/</link>
		<comments>http://www.emanueleferonato.com/2010/02/26/triqui-mochiads-arcade-plugin-for-wordpress-upgraded-to-1-2/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 11:03:48 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Monetize]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2443</guid>
		<description><![CDATA[Yesterday MochiMedia changed the games feed adding a new field called metascore that screwed the feed parsing.
So I am releasing the new version, compatible with the new feed and tested with WordPress 2.9.2. You can find it at the official page.
Talking about plugins, I am developing a new theme/plugin using crontables that automatically feeds the [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiMedia</a> changed the games feed adding a new field called <code>metascore</code> that screwed the feed parsing.</p>
<p>So I am releasing the new version, compatible with the new feed and tested with WordPress 2.9.2. You can find it at the <a href="http://www.emanueleferonato.com/triqui-mochiads-arcade-plugin-for-wordpress-official-page/">official page</a>.</p>
<p>Talking about plugins, I am developing a new theme/plugin using crontables that automatically feeds the games, fixes the tables if <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiMedia</a> updates the feed, and chooses the best games to publish.</p>
<p>Everything without any interaction from the user. The ultimate &#8220;forget about it and make money with your arcade site&#8221; plugin.</p>
<p>Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/26/triqui-mochiads-arcade-plugin-for-wordpress-upgraded-to-1-2/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Box2D Flash game creation tutorial &#8211; part 2</title>
		<link>http://www.emanueleferonato.com/2010/02/25/box2d-flash-game-creation-tutorial-part-2/</link>
		<comments>http://www.emanueleferonato.com/2010/02/25/box2d-flash-game-creation-tutorial-part-2/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 09:56:23 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Box2D]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2434</guid>
		<description><![CDATA[After seeing the character creation in Box2D Flash game creation tutorial &#8211; part 1, it&#8217;s time to add some coins to collect.
This process will involve some interesting Box2D features, like sensors and custom collision management.
I would suggest to read the basics of sensors at Erase Box: the tutorial and custom collision management at Creation of [...]]]></description>
			<content:encoded><![CDATA[<p>After seeing the character creation in <a href="http://www.emanueleferonato.com/2010/02/19/box2d-flash-game-creation-tutorial-part-1/">Box2D Flash game creation tutorial &#8211; part 1</a>, it&#8217;s time to add some coins to collect.</p>
<p>This process will involve some interesting Box2D features, like sensors and custom collision management.</p>
<p>I would suggest to read the basics of sensors at <a href="http://www.emanueleferonato.com/2009/02/25/erase-box-the-tutorial/">Erase Box: the tutorial</a> and custom collision management at <a href="http://www.emanueleferonato.com/2009/11/23/creation-of-a-flash-stabilize-clone-using-box2d-part-4/">Creation of a Flash Stabilize! clone using Box2D – part 4</a>.</p>
<p>Although they are both referred to an older Box2D version, they&#8217;ll introduce you to sensor and collisions.</p>
<p>Now the concept is simple: we are placing some circular sensors around the stage (the coins), then we&#8217;ll create a custom contact listener class to check whether the player is over a coin or not. If it&#8217;s over, we&#8217;ll remove the coin.</p>
<p>So this is the main script:<span id="more-2434"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">KeyboardEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.Shapes.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #004993;">Math</span>.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ball02 extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #009900;">// world creation</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> world<span style="color: #000000; font-weight: bold;">:</span>b2World=<span style="color: #0033ff; font-weight: bold;">new</span> b2World<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">10.0</span><span style="color: #000000;">&#41;</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> world_scale<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">30</span>;
		<span style="color: #009900;">// the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> player<span style="color: #000000; font-weight: bold;">:</span>b2Body;
		<span style="color: #009900;">// force to apply to the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> force<span style="color: #000000; font-weight: bold;">:</span>b2Vec2;
		<span style="color: #009900;">// variables to store whether the keys are pressed or not</span>
		<span style="color: #009900;">// true = pressed;</span>
		<span style="color: #009900;">// false = unpressed</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">left</span>,<span style="color: #004993;">right</span>,up,down<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
		<span style="color: #009900;">// declaring my custom contact listener class</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> contact_listener=<span style="color: #0033ff; font-weight: bold;">new</span> custom_contact_listener<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ball02<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// assigning the contact listener to the world</span>
			world.SetContactListener<span style="color: #000000;">&#40;</span>contact_listener<span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// calling debug draw function</span>
			debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// drawing the boundaries</span>
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;ground&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">200</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;left&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">200</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;right&quot;</span><span style="color: #000000;">&#41;</span>;
			draw_box<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">500</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #990000;">&quot;roof&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// adding the player at 250,200</span>
			add_player<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span>,<span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// adding some coins</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">1</span>; i<span style="color: #000000; font-weight: bold;">&lt;</span>=<span style="color: #000000; font-weight:bold;">5</span>; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				draw_coin<span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">50</span>,<span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">300</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">50</span>,<span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900;">// listeners needed for the game to work</span>
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>, update<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">KeyboardEvent</span>.<span style="color: #004993;">KEY_DOWN</span>,on_key_down<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">KeyboardEvent</span>.<span style="color: #004993;">KEY_UP</span>,on_key_up<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// according to the key pressed, set the proper variable to &quot;true&quot;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> on_key_down<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">keyCode</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">37</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">left</span>=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">38</span> <span style="color: #000000; font-weight: bold;">:</span>
					up=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">39</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">right</span>=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">40</span> <span style="color: #000000; font-weight: bold;">:</span>
					down=<span style="color: #0033ff; font-weight: bold;">true</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// according to the key released, set the proper variable to &quot;false&quot;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> on_key_up<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">KeyboardEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">keyCode</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">37</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">left</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">38</span> <span style="color: #000000; font-weight: bold;">:</span>
					up=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">39</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #004993;">right</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">40</span> <span style="color: #000000; font-weight: bold;">:</span>
					down=<span style="color: #0033ff; font-weight: bold;">false</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function to draw a coin</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> draw_coin<span style="color: #000000;">&#40;</span>px,py,r<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_circle<span style="color: #000000; font-weight: bold;">:</span>b2CircleShape=<span style="color: #0033ff; font-weight: bold;">new</span> b2CircleShape<span style="color: #000000;">&#40;</span>r<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_circle;
			<span style="color: #009900;">// look! it's a sensor!!</span>
			my_fixture.isSensor=<span style="color: #0033ff; font-weight: bold;">true</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> world_body<span style="color: #000000; font-weight: bold;">:</span>b2Body=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			world_body.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// simple function to draw a box</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> draw_box<span style="color: #000000;">&#40;</span>px,py,w,h,<span style="color: #004993;">d</span>,ud<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">d</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				my_body.<span style="color: #004993;">type</span>=b2Body.b2_dynamicBody;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_box<span style="color: #000000; font-weight: bold;">:</span>b2PolygonShape = <span style="color: #0033ff; font-weight: bold;">new</span> b2PolygonShape<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_box.SetAsBox<span style="color: #000000;">&#40;</span>w<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">/</span>world_scale, h<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_box;
			<span style="color: #6699cc; font-weight: bold;">var</span> world_body<span style="color: #000000; font-weight: bold;">:</span>b2Body=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			world_body.SetUserData<span style="color: #000000;">&#40;</span>ud<span style="color: #000000;">&#41;</span>;
			world_body.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function to add the player</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> add_player<span style="color: #000000;">&#40;</span>px,py<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> my_body<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef= <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">/</span>world_scale, py<span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			my_body.<span style="color: #004993;">type</span>=b2Body.b2_dynamicBody;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_circle<span style="color: #000000; font-weight: bold;">:</span>b2CircleShape=<span style="color: #0033ff; font-weight: bold;">new</span> b2CircleShape<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">/</span>world_scale<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> my_fixture<span style="color: #000000; font-weight: bold;">:</span>b2FixtureDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2FixtureDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			my_fixture.shape=my_circle;
			player=world.CreateBody<span style="color: #000000;">&#40;</span>my_body<span style="color: #000000;">&#41;</span>;
			player.CreateFixture<span style="color: #000000;">&#40;</span>my_fixture<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// debug draw</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> debug_draw<span style="color: #000000; font-weight: bold;">:</span>b2DebugDraw = <span style="color: #0033ff; font-weight: bold;">new</span> b2DebugDraw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> debug_sprite<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>debug_sprite<span style="color: #000000;">&#41;</span>;
			debug_draw.SetSprite<span style="color: #000000;">&#40;</span>debug_sprite<span style="color: #000000;">&#41;</span>;
			debug_draw.SetDrawScale<span style="color: #000000;">&#40;</span>world_scale<span style="color: #000000;">&#41;</span>;
			debug_draw.SetFlags<span style="color: #000000;">&#40;</span>b2DebugDraw.e_shapeBit<span style="color: #000000;">&#41;</span>;
			world.SetDebugDraw<span style="color: #000000;">&#40;</span>debug_draw<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function to be executed at every frame</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// setting the force to null</span>
			force=<span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// according to the key(s) pressed, add the proper vector force</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">left</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">right</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>up<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>down<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				force.Add<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900;">// if there is any force, then apply it</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>force.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">||</span>force.<span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				player.ApplyForce<span style="color: #000000;">&#40;</span>force,player.GetWorldCenter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			world.Step<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
			world.ClearForces<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// scanning through all bodies</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> worldbody<span style="color: #000000; font-weight: bold;">:</span>b2Body = world.GetBodyList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; worldbody; worldbody = worldbody.GetNext<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">// if a body is marked as &quot;remove&quot;...</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>worldbody.GetUserData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>==<span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #009900;">// ... just remove it!!</span>
					world.DestroyBody<span style="color: #000000;">&#40;</span>worldbody<span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
			world.DrawDebugData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Let&#8217;s see the interesting lines:</p>
<p><strong>Line 22</strong>: declaring my <code>contact_listener</code> variable, as <code>custom_contact_listener</code> type</p>
<p><strong>Line 25</strong>: assigning my custom contact listener class to Box2D world</p>
<p><strong>Lines 36-38</strong>: calling five times the <code>draw_coin</code> function passing three parameters: x position, y position and radius.</p>
<p><strong>Lines 79-89</strong>: the draw_coin function&#8230; just a basic function that draw a circle&#8230; just notice at <strong>line 86</strong> how I am declaring the circle as a sensor. This way the circle exists in the world but won&#8217;t physically collide with anything. Also, a sensor should be a static body, or it will fall down outside the stage as it won&#8217;t collide with anything.</p>
<p><strong>Lines 150-156</strong>: scanning through all bodies to find, and eventually remove, bodies marked with <code>remove</code>. Such marker is handled by the custom contact listener class, located in the <code>custom_contact_listener.as</code> file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.Shapes.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.Joints.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.Contacts.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #004993;">Math</span>.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #9900cc; font-weight: bold;">class</span> custom_contact_listener extends b2ContactListener <span style="color: #000000;">&#123;</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> BeginContact<span style="color: #000000;">&#40;</span>contact<span style="color: #000000; font-weight: bold;">:</span>b2Contact<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// getting the fixtures that collided</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> fixtureA<span style="color: #000000; font-weight: bold;">:</span>b2Fixture=contact.GetFixtureA<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> fixtureB<span style="color: #000000; font-weight: bold;">:</span>b2Fixture=contact.GetFixtureB<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// if the fixture is a sensor, mark the parent body to be removed</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>fixtureB.IsSensor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				fixtureB.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>fixtureA.IsSensor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				fixtureA.GetBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.SetUserData<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;remove&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><code>BeginContact</code> function will give us the fixtures involved in the collision. Then at <strong>lines 15-17</strong> and <strong>18-20</strong> I am checking if the fixture is a sensor, then eventually mark its parent body to be removed.</p>
<p><strong>Important</strong>: don&#8217;t try to remove the body inside this function, because bodies have a <code>locked</code> status while they are in the middle of a timestep, so you should remove a body only after you performed the <code>Step</code> (<strong>line 147</strong> of the main file). This gave me a little headache, so you&#8217;ve been warned!</p>
<p>This is the result:</p>
<p><embed src="/wp-content/uploads/2010/02/ball02.swf" allowscriptaccess="always" menu="false" quality="high" width="500" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
<p>Pick up all little circles moving the player tapping on arrow keys.</p>
<p><a href="/wp-content/uploads/2010/02/ball02.zip">Download the source code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/25/box2d-flash-game-creation-tutorial-part-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>11 Flash isometric engines you can use in your games</title>
		<link>http://www.emanueleferonato.com/2010/02/23/11-flash-isometric-engines-you-can-use-in-your-games/</link>
		<comments>http://www.emanueleferonato.com/2010/02/23/11-flash-isometric-engines-you-can-use-in-your-games/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 14:45:02 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2400</guid>
		<description><![CDATA[I am playing isometric games for more than 20 years&#8230; probably started with Q*bert, one of the oldest games I played is Head Over Heels on my Commodore 64, and I was an hardcore player of UFO: Enemy Unknown.
As you should know, isometric projection is a method of visually representing three-dimensional objects in two dimensions, [...]]]></description>
			<content:encoded><![CDATA[<p>I am playing isometric games for more than 20 years&#8230; probably started with <a href="http://en.wikipedia.org/wiki/Q*bert" target = "_blank">Q*bert</a>, one of the oldest games I played is <a href="http://en.wikipedia.org/wiki/Head_Over_Heels_(video_game)" target = "_blank">Head Over Heels</a> on my Commodore 64, and I was an hardcore player of <a href="http://en.wikipedia.org/wiki/UFO:_Enemy_Unknown" target = "_blank">UFO: Enemy Unknown</a>.</p>
<p>As you should know, isometric projection is a method of visually representing three-dimensional objects in two dimensions, in which the three coordinate axes appear equally foreshortened and the angles between any two of them are 120 degrees. A great way to represent 3D worlds on old 8-bit computers since their CPUs did not handle a real 3D world, and a great way to create casual adventure games nowadays.</p>
<p>I am showing you a list of 11 Flash isometric engines, some of them are free, others are commercial, and some still unreleased. I am writing to all authors to have more info about their engines, meanwhile this the most complete list I was able to make.</p>
<p>Engines are listed in alphabetical order.</p>
<p><strong>2D isometric engine</strong> &#8211; Free</p>
<p><a href="http://code.google.com/p/2d-isometric-engine/" target = "_blank">http://code.google.com/p/2d-isometric-engine/</a></p>
<p>Open source, multilevel and multiplayer tilebased isometric engine, reviewed in <a href="http://www.emanueleferonato.com/2009/08/18/as3-isometric-engine/">this post</a></p>
<p><strong>as3isolib</strong> &#8211; Free</p>
<p><img src="/wp-content/uploads/2010/02/engines_as3isolib.jpg" /></p>
<p><a href="http://as3isolib.wordpress.com/" target = "_blank">http://as3isolib.wordpress.com/</a></p>
<p>As3isolib is an open-source ActionScript 3.0 Isometric Library developed to assist in creating isometrically projected content (such as games and graphics) targeted for the Flash player platform. As3isolib includes utilities, primitives and views. As3isolib was developed with simplicity, speed and performance in mind so that developers can focus on actual implementations rather than having to learn a complex API.</p>
<p>You can see latest project using this engine at <a href="http://apps.facebook.com/downtowngame/" target = "_blank">http://apps.facebook.com/downtowngame/</a><span id="more-2400"></span></p>
<p><strong>FFilmation</strong> &#8211; Free</p>
<p><img src="/wp-content/uploads/2010/02/engines_ffilmation.jpg" /></p>
<p><a href="http://www.ffilmation.org/" target ="_blank">http://www.ffilmation.org/</a></p>
<p>The FFilmation Engine is an AS3 isometric programing engine, focused mainly on game development. The aim of the project is providing a robust development platform, where game designers can work on the game’s details and forget about the render engine. It is intended to be really usable from a “real production scenario” point of view.</p>
<p>See a demo playing <a href="http://www.ffilmation.org/mynameisponcho/" target = "_blank">My Name is Poncho</a></p>
<p><strong>Flash 3D Isometric Game Engine</strong> &#8211; Unreleased</p>
<p><a href="http://actionscripter.co.uk/blog/?page_id=76" target = "_blank">http://actionscripter.co.uk/blog/?page_id=76</a></p>
<p>Vector isometric engine allowing to zoom, rotate and pan the environment in a &#8220;real&#8221; 3D world. I&#8217;m asking the author more information, stay tuned</p>
<p><strong>isoengineas3</strong> &#8211; Free</p>
<p><a href="http://isoengineas3.sourceforge.net/" target = "_blank">http://isoengineas3.sourceforge.net/</a></p>
<p>2D Isometric Engine project build with Flash AS3. It is an open source, multilevel and multiplayer tilebased isometric engine. No more information.</p>
<p><strong>Isometric Game Engine</strong> &#8211; Unreleased</p>
<p><a href="http://www.davidworks.com/?id=int_iso" target = "_blank">http://www.davidworks.com/?id=int_iso</a></p>
<p>An isometric engine built from scratch for an online virtual campus. No more info.</p>
<p>The <a href="http://www.davidworks.com/content/int_iso/core.htm">demo</a> is quite interesting so I am going to contact the author for more information.</p>
<p><strong>Isometric terrain engine</strong> &#8211; Free</p>
<p><a href="http://yaief.wordpress.com/2008/12/05/isometric-terrain-engine/" target = "_blank">http://yaief.wordpress.com/2008/12/05/isometric-terrain-engine/</a></p>
<p>This is an isometric terrain generator, actually an abandoned project but still an inspiration.</p>
<p><strong>OpenSpace</strong> &#8211; Commercial &#8211; Trial version available</p>
<p><img src="/wp-content/uploads/2010/02/engines_openspace.jpg" /></p>
<p><a href="http://www.openspace-engine.com/">http://www.openspace-engine.com/</a></p>
<p>OpenSpace is a powerful Flash based isometric engine and framework for rapid development of multi-user virtual worlds and MMO communities.</p>
<p>Check <a href="http://www.footballvillage.net/" target ="_blank">Football Village</a> to see it in action.</p>
<p>OpenSpace is licensed on a &#8220;per-seat&#8221; basis: a separate license is required for each user working with OpenSpace.</p>
<p><strong>Sean Cooper Isometric Engine</strong> &#8211; Commercial</p>
<p><a href="http://www.games.seantcooper.com/IsometricEngine.aspx" target ="_blank">http://www.games.seantcooper.com/IsometricEngine.aspx</a></p>
<p>Made by Sean &#8220;BoxHead&#8221; Cooper, the engine is based on some techniques used in the PC game Syndicate, which he wrote in 1993. The technique is simple and extremely fast, well suited to Flash and will run fast on most machines.</p>
<p>At the moment there isn&#8217;t any project showcase, just a demo in the <a href="http://www.games.seantcooper.com/IsometricEngine.aspx" target ="_blank">official page</a>, and no info about the license, but being developed by a PROgrammer like Sean makes this engine quite interesting.</p>
<p><strong>TheoWorlds</strong> &#8211; Commercial</p>
<p><img src="/wp-content/uploads/2010/02/engines_theoworlds.jpg" /></p>
<p><a href="http://www.theoworlds.com/products.php">http://www.theoworlds.com/products.php</a></p>
<p>TheoWorlds Builder SDK v2 is a kit that will help you develop online virtual worlds much faster, without starting from scratch. At its core it contains the original Theo Isometric Engine™ that lets you create pseudo-3D maps, place on them objects and characters, and organize the interaction between them.</p>
<p>You can test the engine playing <a href="http://www.theoworlds.com/games/th/" target = "_blank">Treasure Hunter</a></p>
<p>TheoWorlds Builder SDK v2 is priced $3,200, while the light SDK v1 $799</p>
<p><strong>T.I.L.E. (Tangerine Isometric Level Editor)</strong> &#8211; Commercial</p>
<p><img src="/wp-content/uploads/2010/02/engines_tangerine.jpg" /></p>
<p><a href="http://www.tangerinepop.com/" target ="_blank">http://www.tangerinepop.com/</a> then click on &#8220;tech&#8221;</p>
<p>According to the site, T.I.L.E. provides the ability to rapidly build a standard lock &#038; key adventure game with hundreds of rooms. It also provides the primary software framework needed to build a quality MMO with numerous maps and new play modes via in increasing list of new game mechanics.</p>
<p>An example of a game developed with this technology is <a href="http://www.tangerinepop.com/GraveShift/" target = "_blank">GraveShift</a></p>
<p>Prices range from (as said on the site) &#8220;half to less than half the costs of building it yourself&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/23/11-flash-isometric-engines-you-can-use-in-your-games/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Monetize your Flash games with GamesChart</title>
		<link>http://www.emanueleferonato.com/2010/02/23/monetize-your-flash-games-with-gameschart/</link>
		<comments>http://www.emanueleferonato.com/2010/02/23/monetize-your-flash-games-with-gameschart/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 22:23:00 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Monetize]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Users contributions]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2403</guid>
		<description><![CDATA[Do you remember Emanuele Ornella from Mind the Move? It&#8217;s the guy behind the Come2Play multiplayer API tutorial posted about a month ago.
Now he is explaining us a new way to monetize Flash games: GamesChart
&#171; When I first saw the announcement on Flash Game Developers group on www.linkedIn.com about the GamesChart beta program I immediately [...]]]></description>
			<content:encoded><![CDATA[<p>Do you remember <strong>Emanuele Ornella</strong> from <a target = "_blank" href="http://www.mindthemove.com/">Mind the Move</a>? It&#8217;s the guy behind the <a href="http://www.emanueleferonato.com/2010/01/14/come2play-multiplayer-api-tutorial/">Come2Play multiplayer API tutorial</a> posted about a month ago.</p>
<p>Now he is explaining us a new way to monetize Flash games: <strong><a href="http://gameschart.com/" target = "_blank">GamesChart</a></strong></p>
<p>&laquo; When I first saw the announcement on <a href="http://www.linkedin.com/groups?home=&#038;gid=121017" target = "_blank">Flash Game Developers group</a> on www.linkedIn.com about the <strong><a href="http://gameschart.com/" target = "_blank">GamesChart</a></strong> beta program I immediately thought to participate. It was a surprise to me to find that my game <a href="http://gameschart.com/games/Haunted-House" target = "_blank">Haunted House</a> was at first position for the entire 4 weeks of the beta program!</p>
<p>Actually also my <a href="http://gameschart.com/games/Alice-Memory-1" target = "_blank">Alice Memory</a> game is also on the chart, even if never more than in the 6th position.</p>
<p><img src="/wp-content/uploads/2010/02/gc01.jpg" /></p>
<p>What <strong><a href="http://gameschart.com/" target = "_blank">GamesChart</a></strong> is about?</p>
<p>It’s another way to generate money from you Flash games. The nice thing is that it is not an alternative to the traditional banner you place during the loading of the game. But it goes together.<br />
The main idea is to have publisher to “bid” for which game will be in the chart and this will generate extra revenue to the developer, to the publisher who correctly bid and of course to the GamesChart organization.</p>
<p>This is from <strong>Barry White</strong> directly from linkedIn group.<span id="more-2403"></span></p>
<p>I thought I&#8217;d include some more information about how GamesChart can earn developers money:</p>
<p>+ Every game that has the GamesChart API embedded in it is tracked by GamesChart.</p>
<p>+ The developer can also choose to enable or disable a series of dynamic charts that actually display within the Flash game itself.</p>
<p>+ The most popular games each week make their way to the top of the charts.</p>
<p>+ Any gamers who click on a game listed in these charts is taken to play that game on another portal.</p>
<p>+ Publishers use an advanced pay per click bidding system to purchase this traffic and drive users back to their own sites to play the games they have bid on.</p>
<p>+ Games need to be uploaded to the Publishers portal before they can receive traffic. (great for seeding)</p>
<p>+ Developers receive up to a 50% revenue share of any outbound clicks generated from within their game should they choose to display the charts. (also full blacklisting available)</p>
<p>+ Publishers also receive 10% of total revenues generated from any GamesChart enabled games featured on their site.</p>
<p>I am going to explain the very easy steps to follow to have a game added to this GamesChart.</p>
<p>In order to do so I am going to provide my other game <a href="http://gameschart.com/games/Tokyo-Train" target = "_blank">Tokyo Train</a> with this service as well.</p>
<p>First thing you need to register as developer, if you don’t already. This is quite easy to do, just follow instruction on the site.</p>
<p>You then are prompted to add a game:</p>
<p><img src="/wp-content/uploads/2010/02/gc02.jpg" /></p>
<p>So do not hesitate: go to click the button and create the new game:</p>
<p><img src="/wp-content/uploads/2010/02/gc03.jpg" /></p>
<p>Instructions are easy and nice to follow: I have to admit they did a very good job on make your job easy.</p>
<p><img src="/wp-content/uploads/2010/02/gc04.jpg" /></p>
<p>You are now prompted with the game id that you need to put on the component property to have your game identified.<br />
Of course first of all you need to download the API library from the <a href="http://wiki.gameschart.com/index.php/Getting_Started" target = "_blank">“GamesChart Wiki” link</a>.</p>
<p>You have the choice to get the component for Adobe Flash IDE or the complete API if you use FlashDevelop and for both choices you can choose between AS3 and AS2. My choice was for the component and AS3.</p>
<p>The very first time you download the zip pack, you need to double click on the GamesChartAPI-AS3.mpx:</p>
<p><img src="/wp-content/uploads/2010/02/gc05.jpg" /></p>
<p>This will install the component, and that’s the only thing you really need to install: brilliant.</p>
<p>Now open your FLA and browse for the components (Windows > Components menu): you will find the GamesChartAPI one.</p>
<p><img src="/wp-content/uploads/2010/02/gc06.jpg" /></p>
<p>Now, again it’s easy: drag and drop the component onto the stage (better if at the top layer):</p>
<p><img src="/wp-content/uploads/2010/02/gc07.jpg" /></p>
<p>Do not worry about the position: it will be hidden once the game starts. Do you remember the game id? Go to grab it and paste it in the component inspector:</p>
<p><img src="/wp-content/uploads/2010/02/gc08.jpg" /></p>
<p>That’s all! You can now publish the game: you will notice a small G icon on top right of the stage.</p>
<p>You can force to have this cute icon can be hidden or display when you want. Or you can also move it.</p>
<p>I would suggest you to leave it for the entire game and in that position: it’s the best position, just adjust your buttons if you have any conflict.</p>
<p>In this way a player can click on the icon anytime during the game. This will let him vote your game and show chart. In fact when the icon is clicked the chart will appear and will let you open a new window with the games on the list.</p>
<p><img src="/wp-content/uploads/2010/02/gc09.jpg" /></p>
<p>You need one more thing: to publish the game. You can get your SWF file or you can first upload on MochiAds with version control as I am doing. This is the best solution because your game will be updated all over the world with the cute G icon.<br />
That’s all!<br />
Enjoy!</p>
<p>PS.: I just discovered that Haunted House is no more on first position! So let’s go there and click the cute “G” icon!! &raquo;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/23/monetize-your-flash-games-with-gameschart/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
