<?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 &#187; Game design</title>
	<atom:link href="http://www.emanueleferonato.com/category/game-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emanueleferonato.com</link>
	<description>italian geek and PROgrammer</description>
	<lastBuildDate>Mon, 06 Feb 2012 14:28:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>SamePhysics Flash game source code released</title>
		<link>http://www.emanueleferonato.com/2012/02/06/samephysics-flash-game-source-code-released/</link>
		<comments>http://www.emanueleferonato.com/2012/02/06/samephysics-flash-game-source-code-released/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 14:28:18 +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>
		<category><![CDATA[Monetize]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=5138</guid>
		<description><![CDATA[The source code of SamePhysics, my first Box2D game, is available for download]]></description>
			<content:encoded><![CDATA[<p>More than three years ago I released my first Box2D game called <strong><a href="http://www.emanueleferonato.com/2009/01/12/samephysics-my-first-box2d-game/">SamePhysics</a></strong>.</p>
<p><a href="http://www.emanueleferonato.com/2009/01/12/samephysics-my-first-box2d-game/"><img src="/wp-content/uploads/2012/02/same.jpg" /></a></p>
<p>It was an experiment to port the famous tile based game <a href="http://en.wikipedia.org/wiki/SameGame" target="_blank">SameGame</a> into a real-world physics environment, and despite it was nothing that a prototype with some bugs &#8211; especially with collision management &#8211; the game got some success, with about <strong>2.5 million views</strong> and two sponsorships by Rotten Tomato Games (now offline) and <a href="http://www.girlgames.com/" target="_blank">GirlGames</a>.</p>
<p>Now I am making a sequel of the game, more polished, fun and playable, and it&#8217;s time to release the source code of the good old SamePhysics.</p>
<p>You are warned: the code is &#8220;as is&#8221; and it&#8217;s not even the latest Box2D distribution, but I think it could be interesting to learn the basics of Box2D programming from a real world successful example.</p>
<p><a href="/wp-content/uploads/2012/02/samephysics.zip">Download the source code</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2012/02/06/samephysics-flash-game-source-code-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Making an in-game tutorial with StencylWorks</title>
		<link>http://www.emanueleferonato.com/2012/01/31/making-an-in-game-tutorial-with-stencylworks/</link>
		<comments>http://www.emanueleferonato.com/2012/01/31/making-an-in-game-tutorial-with-stencylworks/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 16:44:10 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[StencylWorks]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=5124</guid>
		<description><![CDATA[Learn how to make in-game tutorials with StencylWorks, making your player "read" the signs placed around a level]]></description>
			<content:encoded><![CDATA[<p>If you are playing the latest Flash games, you will see the old &#8220;how to play&#8221; button no longer exists.</p>
<p>People don&#8217;t want to read detailed instructions before playing a Flash game, they want to dig into action.</p>
<p>That&#8217;s why we have the need to create in-game tutorials, which are easy levels to make players get used to the game design while keeping them in action.</p>
<p>In my upcoming Flash game <strong>Kira the Witch</strong>, the tutorial is made of signs you can find around the levels. Once you touch a sign, you will be able to &#8220;read&#8221; it this way:</p>
<p><iframe width="640" height="480" src="http://www.youtube.com/embed/MZO0vG1W2aA" frameborder="0" allowfullscreen></iframe></p>
<p>I am going to show you how to do it in the painless way.</p>
<p>We have two actors: the small sign and the big sign. Small signs are placed in the scene during level design, while the big sign (one for all) will be created on the fly.</p>
<p>Also, the small sign is a sensor so it won&#8217;t react to physics and has its own collision group, called &#8220;sign&#8221;.</p>
<p>The big sign is a doodad, which means it&#8217;s a special actor never allowed to collide with anything else.</p>
<p>There is a big difference between a sensor and a doodad. The sensor does not react to physics forces but registers collisions, the doodad does not register collisions.</p>
<p>Now let&#8217;s create some behaviors: the first, and the easiest, is called &#8220;Big sign information&#8221; and does not contain any action, as you can see:</p>
<p><img src="/wp-content/uploads/2012/01/sign01.png" /></p>
<p>So it may seems useless, but I added to this behavior three not hidden attributes called &#8220;Text to display&#8221;, &#8220;Big sign x position&#8221; and &#8220;Big sign y position&#8221;.</p>
<p>When I customize the behavior of each small sign and add &#8220;Big sign information&#8221; behavior&#8230;</p>
<p><img src="/wp-content/uploads/2012/01/sign02.png" /></p>
<p>I can set the each sign content, and the x and y coordinates to be shown once Kira &#8220;reads&#8221; a sign. This way, &#8220;Big sign information&#8221; behavior acts like a new data type:</p>
<p><img src="/wp-content/uploads/2012/01/sign03.png" /></p>
<p>Also please notice I am using an asterisk as line break character since using &#8220;\n&#8221; won&#8217;t work at this stage.</p>
<p>Then, I need another behavior called &#8220;Write sign text&#8221; which will write text inside the big sign, so obvioulsy will be tied to it:</p>
<p><img src="/wp-content/uploads/2012/01/sign04.png" /></p>
<p>This is also very easy as I am only setting a font and writing some text in the sign. Notice how at this time I need to replace &#8220;*&#8221; with &#8220;\n&#8221; to do line breaks.</p>
<p>The difficult task to create the big sign, place it, and write text in it by changing &#8220;Text to write&#8221; attribute is (and then remove it) made by main player&#8217;s behavior called &#8220;Kira touches a sign&#8221;</p>
<p><img src="/wp-content/uploads/2012/01/sign05.png" /></p>
<p>I commented it to let you understand how it works.</p>
<p>Basically the key is the communication among different behaviors to get and set attributes on the fly.</p>
<p>And we can say &#8220;goodbye&#8221; to that old lame &#8220;How to play&#8221; buttons in a matter of minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2012/01/31/making-an-in-game-tutorial-with-stencylworks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Play Slingy, my latest Flash game, on Hairy Games</title>
		<link>http://www.emanueleferonato.com/2012/01/27/play-slingy-my-latest-flash-game-on-hairy-games/</link>
		<comments>http://www.emanueleferonato.com/2012/01/27/play-slingy-my-latest-flash-game-on-hairy-games/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 15:48:07 +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>
		<category><![CDATA[Monetize]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=5113</guid>
		<description><![CDATA[Play <a href="http://www.hairygames.com/play-slingy.html" target = "_blank">Slingy</a>, my latest physics Flash Game sponsored by <a href="http://www.hairygames.com/" target="_blank">Hairy Games</a>]]></description>
			<content:encoded><![CDATA[<p>I want you all to play <a href="http://www.hairygames.com/play-slingy.html" target="_blank">Slingy</a>, my latest Flash game, sponsored by <strong><a href="http://www.hairygames.com/" target="_blank">Hairy Games</a></strong>.</p>
<p><a href="http://www.hairygames.com/play-slingy.html" target = "_blank"><img src="/wp-content/uploads/2012/01/slingygame1.jpg" alt="" title="slingygame" width="640" height="480" class="alignnone size-full wp-image-5114" /></a></p>
<p>In this physics game you have to beat all 40 levels collecting as much orbs as you can, throwing the ball with a sling. To make your life harder, several kind of blocks to avoid or interact with.</p>
<p>You can find some information about the prototype in these posts:</p>
<p>* <a href="http://www.emanueleferonato.com/2007/09/01/controlling-a-ball-like-in-flash-elasticity-game-tutorial/">Controlling a ball like in Flash Elasticity game tutorial</a><br />
* <a href="http://www.emanueleferonato.com/2010/03/25/flash-elasticity-prototype-as3-version/">Flash Elasticity prototype – AS3 version</a><br />
* <a href="http://www.emanueleferonato.com/2007/12/18/when-elasticity-meets-bloons/">When Elasticity meets Bloons</a></p>
<p>The physics is powered by <a href="http://www.emanueleferonato.com/category/box2d/">Box2D</a>, while I used <a href="http://flintparticles.org/" target="_blank">Flint particle system</a> for the particles.</p>
<p>Talking about advertising, I used <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target="_blank">MochiMedia</a> for the in-game ads and <a href="http://www.flashgamelicense.com/" target="_blank">FlashGameLicense</a> to find a sponsorship.</p>
<p>I recommend Rick from <a href="http://www.hairygames.com/" target="_blank">Hairy Games</a>: he provides constructive feedback, helps you to make the game better and the branding process is easy.</p>
<p>I also used both <a href="http://www.playtomic.com/" target="_blank">Playtomic</a> and <a href="http://www.mochibot.com/" target="_blank">MochiBot</a> to track game statistics.</p>
<p><a target = "_blak" href="http://www.hairygames.com/play-slingy.html">Play ita</a>, rate it and give me feedback.</p>
<p>I will update you with some interesting new about the game once it&#8217;s in the wild for some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2012/01/27/play-slingy-my-latest-flash-game-on-hairy-games/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>The concept behind Stringy Flash game: determine if a Sprite is inside a lasso</title>
		<link>http://www.emanueleferonato.com/2012/01/25/the-concept-behind-stringy-flash-game-determine-if-a-sprite-is-inside-a-lasso/</link>
		<comments>http://www.emanueleferonato.com/2012/01/25/the-concept-behind-stringy-flash-game-determine-if-a-sprite-is-inside-a-lasso/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 16:34:42 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=5105</guid>
		<description><![CDATA[Collect stuff drawing a lasso around it like in <a href = "http://www.kongregate.com/games/triqui/stringy?src=ref-x-dev-site-x-efblog" target = "_blank">Stringy Flash game</a>]]></description>
			<content:encoded><![CDATA[<p>Do you remember my Flash game called <a href="http://www.kongregate.com/games/triqui/stringy?src=ref-x-dev-site-x-efblog" target="_blank">Stringy</a>?</p>
<p>I blogged about it <a href="http://www.emanueleferonato.com/2011/12/16/play-stringy-my-latest-flash-game/">about a month ago</a> and some people asked me some hints about the way used to catch the stars drawing a lasso around it.</p>
<p>There are a lot of mathematical formulas to solve this task, and range from &#8220;more than complicate&#8221; to &#8220;you must be joking&#8221;.</p>
<p>I decided to post a prototype of the code I used starting from the post <a href="http://www.emanueleferonato.com/2011/10/13/develop-a-flash-game-like-string-avoider-as3-version-and-more/">Develop a Flash game like String Avoider – AS3 version – and more!</a>, without any comment, and it will be up to you to guess how I solved the problem in a ridiculously easy way.</p>
<p>This is what you will get:</p>
<p><embed src="/wp-content/uploads/2012/01/stringyconcept.swf" menu="false" quality="high" width="640" height="480" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
<p>Catch the circle with a lasso to make it move in a random spot.</p>
<p>And this is the code:</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
</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: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> tailLenght<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> tailNodes<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> tailCanvas<span style="color: #000066; 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: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> areaCanvas<span style="color: #000066; 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: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> targetCanvas<span style="color: #000066; 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: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> nodes<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>Point<span style="color: #000066; font-weight: bold;">&gt;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>Point<span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<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;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">&lt;</span>tailNodes<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>areaCanvas<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>tailCanvas<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>targetCanvas<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			placeTarget<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span>update<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> placeTarget<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">target</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">600</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">440</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			targetCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			targetCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span>0xffffff<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			targetCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0xffffff<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			targetCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawCircle</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			targetCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> sampleNodes<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>Point<span style="color: #000066; font-weight: bold;">&gt;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>Point<span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			tailCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			tailCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">,</span>0x00ff00<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			tailCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			areaCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			nodes<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			sampleNodes<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</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: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">&lt;</span>tailNodes<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> nodeAngle<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">atan2</span><span style="color: #000000;">&#40;</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">-</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>x<span style="color: #000066; font-weight: bold;">-</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">+</span>tailLenght<span style="color: #000066; font-weight: bold;">*</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">cos</span><span style="color: #000000;">&#40;</span>nodeAngle<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">+</span>tailLenght<span style="color: #000066; font-weight: bold;">*</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">sin</span><span style="color: #000000;">&#40;</span>nodeAngle<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				tailCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>i<span style="color: #000066; font-weight: bold;">%</span>10==<span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000066; font-weight: bold;">||</span> i==tailNodes<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					sampleNodes<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">&lt;</span>sampleNodes<span style="color: #000066; font-weight: bold;">.</span>length<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</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> j<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span>=i<span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span> j<span style="color: #000066; font-weight: bold;">&lt;</span>sampleNodes<span style="color: #000066; font-weight: bold;">.</span>length<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> j<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #6699cc; font-weight: bold;">var</span> p<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span>=lineIntersection<span style="color: #000000;">&#40;</span>sampleNodes<span style="color: #000000;">&#91;</span>j<span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span>sampleNodes<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span>sampleNodes<span style="color: #000000;">&#91;</span>i<span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span>sampleNodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>p<span style="color: #000066; font-weight: bold;">!</span>=<span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">!</span><span style="color: #004993;">isNaN</span><span style="color: #000000;">&#40;</span>p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
						areaCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0xff0000<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						areaCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span>p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>p<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</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> k<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span>=i<span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> k<span style="color: #000066; font-weight: bold;">&lt;</span>=j<span style="color: #000066; font-weight: bold;">;</span> k<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
							areaCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span>sampleNodes<span style="color: #000000;">&#91;</span>k<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>sampleNodes<span style="color: #000000;">&#91;</span>k<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						<span style="color: #000000;">&#125;</span>
						areaCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #000000;">&#125;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>areaCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">hitTestPoint</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				placeTarget<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> lineIntersection<span style="color: #000000;">&#40;</span>p1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">,</span>p2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">,</span>p3<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">,</span>p4<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> x1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=p1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> x2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=p2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> x3<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=p3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> x4<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=p4<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> y1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=p1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> y2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=p2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> y3<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=p3<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> y4<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=p4<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> px<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x1<span style="color: #000066; font-weight: bold;">*</span>y2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span>y1<span style="color: #000066; font-weight: bold;">*</span>x2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>x3<span style="color: #000066; font-weight: bold;">-</span>x4<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000;">&#40;</span>x1<span style="color: #000066; font-weight: bold;">-</span>x2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x3<span style="color: #000066; font-weight: bold;">*</span>y4<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span>y3<span style="color: #000066; font-weight: bold;">*</span>x4<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x1<span style="color: #000066; font-weight: bold;">-</span>x2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>y3<span style="color: #000066; font-weight: bold;">-</span>y4<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000;">&#40;</span>y1<span style="color: #000066; font-weight: bold;">-</span>y2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>x3<span style="color: #000066; font-weight: bold;">-</span>x4<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> py<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x1<span style="color: #000066; font-weight: bold;">*</span>y2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span>y1<span style="color: #000066; font-weight: bold;">*</span>x2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>y3<span style="color: #000066; font-weight: bold;">-</span>y4<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000;">&#40;</span>y1<span style="color: #000066; font-weight: bold;">-</span>y2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x3<span style="color: #000066; font-weight: bold;">*</span>y4<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span>y3<span style="color: #000066; font-weight: bold;">*</span>x4<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x1<span style="color: #000066; font-weight: bold;">-</span>x2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>y3<span style="color: #000066; font-weight: bold;">-</span>y4<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000;">&#40;</span>y1<span style="color: #000066; font-weight: bold;">-</span>y2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>x3<span style="color: #000066; font-weight: bold;">-</span>x4<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> segment1Len<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p1<span style="color: #000066; font-weight: bold;">.</span>x<span style="color: #000066; font-weight: bold;">-</span>p2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p1<span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">-</span>p2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> segment2Len<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p3<span style="color: #000066; font-weight: bold;">.</span>x<span style="color: #000066; font-weight: bold;">-</span>p4<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p3<span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">-</span>p4<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p1<span style="color: #000066; font-weight: bold;">.</span>x<span style="color: #000066; font-weight: bold;">-</span>px<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p1<span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">-</span>py<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">&gt;</span>segment1Len<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</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;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p2<span style="color: #000066; font-weight: bold;">.</span>x<span style="color: #000066; font-weight: bold;">-</span>px<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p2<span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">-</span>py<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">&gt;</span>segment1Len<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</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;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p3<span style="color: #000066; font-weight: bold;">.</span>x<span style="color: #000066; font-weight: bold;">-</span>px<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p3<span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">-</span>py<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">&gt;</span>segment2Len<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</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;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p4<span style="color: #000066; font-weight: bold;">.</span>x<span style="color: #000066; font-weight: bold;">-</span>px<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span>p4<span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">-</span>py<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">&gt;</span>segment2Len<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span>px<span style="color: #000066; font-weight: bold;">,</span>py<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</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>No need to download anything, you can replace the code contained in the <a href="http://www.emanueleferonato.com/2011/10/13/develop-a-flash-game-like-string-avoider-as3-version-and-more/">original prototype</a> with this one.</p>
<p>Did you figure out how I made it possible with no formulas?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2012/01/25/the-concept-behind-stringy-flash-game-determine-if-a-sprite-is-inside-a-lasso/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Make the player die after a long fall with StencylWorks</title>
		<link>http://www.emanueleferonato.com/2012/01/23/make-the-player-die-after-a-long-fall-with-stencylworks/</link>
		<comments>http://www.emanueleferonato.com/2012/01/23/make-the-player-die-after-a-long-fall-with-stencylworks/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 10:01:25 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[StencylWorks]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=5089</guid>
		<description><![CDATA[Learn how to make a StencylWorks platform game featuring death for falling from high places]]></description>
			<content:encoded><![CDATA[<p>I already showed you how easy is to <a href="http://www.emanueleferonato.com/2011/12/05/create-awesome-flash-games-in-no-time-with-stencylworks-adding-intro-jumping-and-more/">create a platform game with StencylWorks</a> and even how to include a <a href="http://www.emanueleferonato.com/2012/01/10/develop-double-jump-behavior-in-stencylworks/">double jump</a> feature.</p>
<p>Anyway, in some platform games you need to make the player die if falling from high places.</p>
<p>Try to play this prototype:</p>
<p><embed src="/wp-content/uploads/2012/01/deadly.swf" menu="false" quality="high" width="640" height="480" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
<p>You can play with ARROW keys, and perform double jumps.</p>
<p>If you fall down the left cliff, you will die (actually, you turn gray for couple of seconds &#8211; that&#8217;s how I show you would have died).</p>
<p>If you fall down the right cliff, you won&#8217;t die.</p>
<p>If you jump from the right cliff and fall down, you will die.</p>
<p>This happens because there&#8217;s a maximum falling height. If you&#8217;re falling for more than such height, you will die.</p>
<p>To make this kind of behavior, first we need some attributes:</p>
<p><img src="/wp-content/uploads/2012/01/deadly03.jpg" /></p>
<p><strong>is falling</strong> is a Boolean variable to determine whether the player is falling or not</p>
<p><strong>falling start</strong> is the y coordinate in pixels of the player when it begins to fall</p>
<p><strong>deadly height</strong> is the height, in pixels, of the deadly height. Also notice this attribute is not hidden so it can be set when the behavior is added to the player:</p>
<p><img src="/wp-content/uploads/2012/01/deadly01.jpg" /></p>
<p>Then, this is the behavior:</p>
<p><img src="/wp-content/uploads/2012/01/deadly02.jpg" /></p>
<p>As you can see it&#8217;s just a matter of checking if player&#8217;s y speed is greater than zero (the player is moving down, so it&#8217;s falling), and once it hits the ground again, calculating for how long it kept on falling.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2012/01/23/make-the-player-die-after-a-long-fall-with-stencylworks/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Attend the Flash Gaming Summit 2012 with a 15% OFF!</title>
		<link>http://www.emanueleferonato.com/2012/01/11/attend-the-flash-gaming-summit-2012-with-a-15-off/</link>
		<comments>http://www.emanueleferonato.com/2012/01/11/attend-the-flash-gaming-summit-2012-with-a-15-off/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 20:41:15 +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=5068</guid>
		<description><![CDATA[The <strong><a href="http://www.flashgamingsummit.com/" target="_blank">Flash Gaming Summit</a></strong> is the leading annual one-day conference dedicated to fostering the growth and success of the Flash games community. Now you can attend it with a 15% OFF!]]></description>
			<content:encoded><![CDATA[<p>Do you love to work in Flash games industry? The <strong><a href="http://www.flashgamingsummit.com/" target="_blank">Flash Gaming Summit</a></strong> is the leading annual one-day conference dedicated to fostering the growth and success of the Flash games community. In this 4th edition, on March 4th, 2012 San Francisco will host the biggest names in the Flash games space to share industry insights and strategies on successful game design, development, and monetization.</p>
<p><a href="http://www.flashgamingsummit.com/" target = "_blank"><img src="/wp-content/uploads/2012/01/fgs.jpg" alt="" title="fgs" width="640" height="333" class="alignnone size-full wp-image-5069" /></a> </p>
<p>The official theme for FGS 2012 is <strong>Maximize Your Game</strong>. Why? Game developers (and the industry in general) are doing amazing things with Flash games. We are seeing games being designed and created (maximized) for multiple devices and platforms. Developers are increasing (maximizing) the value of their IP. Game designers and artists are improving (maximizing) the overall quality of their games. New tools and resources are available to help improve (maximize) development time. Marketing and monetization strategies are emerging to enhance (maximize) overall game distribution, discovery, and revenue streams. Maximize Your Game reflects all of the exciting innovation we are seeing in the Flash games industry today.</p>
<p>Moreover, there is space for speakers in the following topics:</p>
<p>* Mobile-specific<br />
* Design<br />
* Development<br />
* Marketing strategy<br />
* Designing for multiple devices<br />
* Game post-mortems<br />
* Game Development<br />
* Multi-player<br />
* Developing for multiple platforms<br />
* Development tools<br />
* Performance optimization<br />
* Game Design<br />
* Design tips &#038; tricks<br />
* Game post-mortems<br />
* 3D-specific<br />
* Pros and cons<br />
* Optimizing 2D performance<br />
* Using Stage 3D<br />
* Game post-mortems<br />
* Business<br />
* Building a business (going from one person to a small team)<br />
* Artwork<br />
* Graphics<br />
* Animation</p>
<p>And it&#8217;s not over yet! Sign up for the conference with the discount code <a href="http://www.eventbrite.com/discounts?eid=2363661776&#038;discount=2574847" target="_blank">blog_Emanuele</a> (hey! It&#8217;s me!!) and attend the summit with a 15% OFF!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2012/01/11/attend-the-flash-gaming-summit-2012-with-a-15-off/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Develop double jump behavior in StencylWorks</title>
		<link>http://www.emanueleferonato.com/2012/01/10/develop-double-jump-behavior-in-stencylworks/</link>
		<comments>http://www.emanueleferonato.com/2012/01/10/develop-double-jump-behavior-in-stencylworks/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 16:31:56 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[StencylWorks]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=5056</guid>
		<description><![CDATA[Learn how to make a double jump behavior with StencylWorks. Very useful for your platform games.]]></description>
			<content:encoded><![CDATA[<p>One of the most interesting features to add in a platform game is the double jump.</p>
<p>This means the player can jump, and while in the air, can jump once more to get higher platforms.</p>
<p>Something like this demo made with <a href="http://www.stencyl.com/stencylworks/overview/" target="_blank">StencylWorks</a>, taken from my upcoming game <strong>Kira the Witch</strong>:</p>
<p><embed src="/wp-content/uploads/2012/01/doublejump.swf" menu="false" quality="high" width="640" height="480" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
<p>Move with LEFT and RIGHT arrow keys, jump and double jump with UP arrow key.</p>
<p>I already showed you how to make an actor jump in the post <a href="http://www.emanueleferonato.com/2011/12/05/create-awesome-flash-games-in-no-time-with-stencylworks-adding-intro-jumping-and-more/">Create awesome Flash games in no time with StencylWorks – adding intro, jumping and more</a>, but when we want a double jump, we need two more attributes: one to see if we are jumping, that is if we are in the air because we made a jump (and not because we are falling down a platform) and one to determine if we can perform a double jump.</p>
<p>In the end, the double jump can be made only when you jump, and before you touch the ground you release the jump key and then press it again.</p>
<p>That is, the behavior you can see here:</p>
<p><img src="/wp-content/uploads/2012/01/doublejump.jpg" /></p>
<p>Useless to say, really easy, like all <a href="http://www.stencyl.com/stencylworks/overview/" target="_blank">StencylWorks</a> features.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2012/01/10/develop-double-jump-behavior-in-stencylworks/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>One game, many frameworks</title>
		<link>http://www.emanueleferonato.com/2012/01/03/one-game-many-frameworks/</link>
		<comments>http://www.emanueleferonato.com/2012/01/03/one-game-many-frameworks/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 16:23:07 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Users contributions]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=5037</guid>
		<description><![CDATA[Ever wanted to build a mobile game using a framework? <strong>Roger Engelbert</strong> built a guide to do it with <strong>four</strong> different frameworks!]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s no doubt 2012 will be the year of the frameworks. <strong><strong>Roger Engelbert</strong></strong> in his blog <a href="http://www.rengelbert.com/" target="_blank">rengelbert.com</a> show us how to do a mobile Frogger game using four different frameworks: <a href="http://www.starling-framework.org/" target="_blank">Starling</a>, <a href="http://www.sparrow-framework.org/" target="_blank">Sparrow</a>, <a href="http://cocos2d.org/" target="_blank">Cocos2D</a> and <a href="http://libgdx.badlogicgames.com/" target="_blank">LibGDX</a>.</p>
<p>This is the game involved in the experiment:</p>
<p><center><embed src="/wp-content/uploads/2012/01/FroggerAS3.swf" menu="false" quality="high" width="320" height="480" wmode="direct" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></center></p>
<p>Use arrow keys to move the frog, or click on the frog controller in the bottom right corner of the game.</p>
<p>Here is a brief intro by Roger:</p>
<p>I will first explain something of the logic controlling the game. It is very important to point out that the logic itself has nothing to do with any of the frameworks I&#8217;ll use. The frameworks for the most part only influence the VIEW part of the logic: the actual rendering of textures on screen in place of all the rectangle objects the logic handles.</p>
<p>So these tutorials are not meant to be on how to build a game like Frogger, but how to blitt stuff to the screen.</p>
<p>Having said that, I thought I might as well explain enough of the game logic so that you can separate that logic from the actual framework code.</p>
<p><strong>The Game Engine</strong></p>
<p>The engine manages a series of Screen objects, but displays only one screen at a time. So you can build an Intro Screen, a How to Play Screen, a High Scores Screen, a Game Screen&#8230; The Engine then updates the currently displayed Screen object within a loop.</p>
<p>For this example I created two screens, one called a MenuScreen that shows the instructions on how to play the game, and one screen called GameScreen where the actual game runs.</p>
<p>The main Game object contains exposed references to GameData, the TextureAtlas and Sounds. Every object in the game receives a reference to the Game object. I&#8217;ve decide to use composition and drop the Singletons.</p>
<p><strong>Controls</strong></p>
<p>For the Flash version of the game I will use two sets of controls: Key presses and Mouse clicks. Later when porting to mobile devices I will drop the Keyboard input logic and just keep the touch events.</p>
<p><strong>The Game Logic</strong></p>
<p>The game logic is very simple. The screen is divided into 13 rows, I called them Tiers. Each Tier has a bunch of sprites inside it, they can be cars, or turtles or tree logs.</p>
<p>The frog sprite, controlled by the player, can have only 13 possible values for its Y position, one value per Tier. So with every UP or DOWN movement the player Y value changes to either the next Tier or the previous one.</p>
<p>Collision is run only with the objects belonging to the Tier the frog is currently at.</p>
<p>Each Tier has the responsibility to update the positions of the sprites it contains.</p>
<p><strong>The Skin Property</strong></p>
<p>As I talked about earlier, the different frameworks used will be in charge of the SKIN property of the Sprites used in the game as well as the various Texture objects a skin may use (if it&#8217;s animated for instance.) It is here that the Framework logic and syntax can be found.</p>
<p>However when I update the position of sprites in the game I do this through the wrappers and not directly to the Image objects. This might seem like extra work for you, and you&#8217;re free to change this. I simply find this way to be the easiest when taking the same logic to different platforms as I only need to change the logic controlling rendering of the skins.</p>
<p>Now, you are ready to ready one of the most interesting tutorials I&#8217;ve ever seen.</p>
<p><a href="http://www.rengelbert.com/tutorial.php?id=163" target="_blank">http://www.rengelbert.com/tutorial.php?id=163</a> (using Starling)<br />
<a href="http://www.rengelbert.com/tutorial.php?id=167" target="_blank">http://www.rengelbert.com/tutorial.php?id=167</a> (using Sparrow)<br />
<a href="http://www.rengelbert.com/tutorial.php?id=171" target="_blank">http://www.rengelbert.com/tutorial.php?id=171</a> (using Cocos2D)<br />
<a href="http://www.rengelbert.com/tutorial.php?id=175" target="_blank">http://www.rengelbert.com/tutorial.php?id=175</a> (using LibGDX)</p>
<p>I am looking forward for playing and messing around with frameworks and publish my thoughts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2012/01/03/one-game-many-frameworks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Manage saved games with StencylWorks</title>
		<link>http://www.emanueleferonato.com/2011/12/27/manage-saved-games-with-stencylworks/</link>
		<comments>http://www.emanueleferonato.com/2011/12/27/manage-saved-games-with-stencylworks/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 10:11:28 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[StencylWorks]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=5004</guid>
		<description><![CDATA[How to use StencylWorks to manage saved games as the player progresses through the levels]]></description>
			<content:encoded><![CDATA[<p>Some days ago I showed you how to <a href="http://www.emanueleferonato.com/2011/12/13/create-awesome-flash-games-in-no-time-with-stencylworks-selecting-levels/">select level with StencylWorks</a>, but selecting levels is useless if your game does not keep track of player progresses unlocking new levels as previous levels have been completed.</p>
<p>And, even more important, you should be able to manage saved games so players won&#8217;t be forced to complete the game in a single session.</p>
<p>Two posts which explain how to do it respectively with AS2 and AS3 are <a href="http://www.emanueleferonato.com/2008/01/02/managing-savegames-with-flash-shared-objects/">managing savegames with Flash shared objects</a> and <a href="http://www.emanueleferonato.com/2008/12/28/understanding-as3-shared-objects/">understanding AS3 shared objects</a>.</p>
<p>Obviously, with StencylWorks everything is easier.</p>
<p>First, we start with the creation of another animation for the door actor, which now will have two animations (two static images in this case, but it&#8217;s the same for the scope of this post).</p>
<p>One for the open, clickable door which will bring us to an unlocked level, and one for the closed, not clickable door, which represents the locked levels.</p>
<p><img src="/wp-content/uploads/2011/12/shared01.jpg" /></p>
<p>Then we have to create two game attributes. Game attributes are global variables which are accessible to every behavior. I am calling them &#8220;Highest Level Completed&#8221; and &#8220;Current Level&#8221; and I will use them to store respectively the number of the highest level completed and the current level being played. Both attributes have a starting value of zero.</p>
<p>Using game attributes for this purpose is very important, as StencylWorks allows you to save and load all game attributes.</p>
<p><img src="/wp-content/uploads/2011/12/shared02.jpg" /></p>
<p>Now we need to create a behavior to load game attributes, which should be executed as soon as possible, so you&#8217;d better bind it to the splash screen. It&#8217;s very easy as StencylWorks has a &#8220;load save file&#8221; block.</p>
<p><img src="/wp-content/uploads/2011/12/shared03.jpg" /></p>
<p>Now, the hardest task: show open gates for playable levels and make them clickable, and closed gates for unplayable levels. Modify the &#8220;Click to play level&#8221; behavior I showed you in <a href="http://www.emanueleferonato.com/2011/12/13/create-awesome-flash-games-in-no-time-with-stencylworks-selecting-levels/">create awesome Flash games in no time with StencylWorks &#8211; Selecting levels</a> this way:</p>
<p><img src="/wp-content/uploads/2011/12/shared04.jpg" /></p>
<p>Let&#8217;s see what changed:</p>
<p>In the &#8220;always&#8221; block you can see the behavior has a new attribute called &#8220;level number&#8221; and it can be clicked only if the value of &#8220;Highest Level Completed&#8221; game attribute is greater or equal than &#8220;level number&#8221; attribute.</p>
<p>If it&#8217;s true, then we set &#8220;Current Level&#8221; game attribute to &#8220;level number&#8221; value and we make the player to to the level.</p>
<p>The &#8220;when drawing&#8221; block will also check for &#8220;Highest Level Completed&#8221; game attribute to be greater or equal to &#8220;level number&#8221; attribute, and will show the &#8220;Open&#8221; door animation, along with the level number, if true. Otherwise, the &#8220;Closed&#8221; door animation will be shown.</p>
<p>At this time, we have to customize the behavior of each door, just like you made in the <a href="http://www.emanueleferonato.com/2011/12/13/create-awesome-flash-games-in-no-time-with-stencylworks-selecting-levels/">previous step</a>, this time setting also &#8220;level number&#8221; attribute to zero for level one, then one for level two, and so on. </p>
<p><img src="/wp-content/uploads/2011/12/shared05.jpg" /></p>
<p>Finally, once the player completes a level, in this case when the player hits the door, we have to set &#8220;Highest Level Completed&#8221; game variable to the larger number between &#8220;Highest Level Completed&#8221; game variable itself and &#8220;Current Level&#8221; game variable.</p>
<p>Then, you can save the game. This way, &#8220;Highest Level Completed&#8221; variable will be locally saved, and made available once you launch the game again.</p>
<p><img src="/wp-content/uploads/2011/12/shared06.jpg" /></p>
<p>This is what you should see once you beat level two:</p>
<p><img src="/wp-content/uploads/2011/12/shared07.jpg" /></p>
<p>I am making a complete game without writing a single line of code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2011/12/27/manage-saved-games-with-stencylworks/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>iPhone String Avoider prototype with Adobe Flash Professional CS5.5</title>
		<link>http://www.emanueleferonato.com/2011/12/21/iphone-string-avoider-prototype-with-adobe-flash-professional-cs5-5/</link>
		<comments>http://www.emanueleferonato.com/2011/12/21/iphone-string-avoider-prototype-with-adobe-flash-professional-cs5-5/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 10:49:42 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=4994</guid>
		<description><![CDATA[An experiment to port Stringy engine to iPhone using Adobe Flash Professional CS5.5]]></description>
			<content:encoded><![CDATA[<p>I am considering to port <a href="http://www.emanueleferonato.com/2011/12/16/play-stringy-my-latest-flash-game/">Stringy</a> on the iPhone and after seeing the <a href="http://www.emanueleferonato.com/2011/12/19/develop-a-string-avoider-prototype-with-corona-sdk/">Corona SDK example</a> I tried to convert the <a href="http://www.emanueleferonato.com/2011/10/13/develop-a-flash-game-like-string-avoider-as3-version-and-more/">AS3 String Avoider prototype</a> for the iPhone, using the guidelines in the post <a href="http://www.emanueleferonato.com/2011/09/22/creation-of-an-iphone-app-with-flash-and-without-a-mac-for-all-windows-lovers/">Creation of an iPhone App with Flash and without a Mac</a>.</p>
<p>So, I wrote this code:</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> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> final <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> static const tailLenght<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> static const tailNodes<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> static const head<span style="color: #000066; font-weight: bold;">:</span>Head=<span style="color: #0033ff; font-weight: bold;">new</span> Head<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> static const tailCanvas<span style="color: #000066; 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: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> static const bg<span style="color: #000066; font-weight: bold;">:</span>Background=<span style="color: #0033ff; font-weight: bold;">new</span> Background<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> nodes<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>Point<span style="color: #000066; font-weight: bold;">&gt;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>Point<span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> followTheMouse<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>bg<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			bg<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">cacheAsBitmap</span>=<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>head<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">cacheAsBitmap</span>=<span style="color: #0033ff; font-weight: bold;">true</span>
			head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span>=<span style="color: #000000; font-weight:bold;">160</span><span style="color: #000066; font-weight: bold;">;</span>
			head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span>=<span style="color: #000000; font-weight:bold;">240</span><span style="color: #000066; font-weight: bold;">;</span>
			head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_DOWN</span><span style="color: #000066; font-weight: bold;">,</span>followMouse<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>tailCanvas<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</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: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">&lt;</span>tailNodes<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span>head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span>update<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_UP</span><span style="color: #000066; font-weight: bold;">,</span>stopMouse<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> followMouse<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			followTheMouse=<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
			head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span>=<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> stopMouse<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			followTheMouse=<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
			head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span>=<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>followTheMouse<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span>=<span style="color: #004993;">mouseX</span><span style="color: #000066; font-weight: bold;">;</span>
				head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span>=<span style="color: #004993;">mouseY</span><span style="color: #000066; font-weight: bold;">;</span>
				tailCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				tailCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span>0xffffff<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				tailCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span>head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				nodes<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span>head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>head<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</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: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">&lt;</span>tailNodes<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #6699cc; font-weight: bold;">var</span> nodeAngle<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">atan2</span><span style="color: #000000;">&#40;</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">-</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>x<span style="color: #000066; font-weight: bold;">-</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">+</span>tailLenght<span style="color: #000066; font-weight: bold;">*</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">cos</span><span style="color: #000000;">&#40;</span>nodeAngle<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">+</span>tailLenght<span style="color: #000066; font-weight: bold;">*</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">sin</span><span style="color: #000000;">&#40;</span>nodeAngle<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					tailCanvas<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>nodes<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900; font-style: italic;">// do other stuff in the game</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>Which is basically the same as the <a href="http://www.emanueleferonato.com/2011/10/13/develop-a-flash-game-like-string-avoider-as3-version-and-more/">original prototype</a>, just dragging the string when the finger (mouse) is down and showing a circle where to tap (click) to start dragging again if the player leaves the finger (releases mouse button).</p>
<p>Play with the result:</p>
<p><center><embed src="/wp-content/uploads/2011/12/iStringy.swf" menu="false" quality="high" width="320" height="480" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></center></p>
<p>Drag the white circle to move the string.</p>
<p>I also optimized a bit the code defining the class as <code>final</code> since it&#8217;s not meant for being extended and its methods aren&#8217;t meant for being overridden. <code>final</code> classes should execute faster than other classes, and since I am looking for the best performance improvement, I used this trick.</p>
<p>Using <code>static</code> in some variable declarations also should increase the speed. <code>static</code> specifies that a variable (or a constant) belongs to the class rather than to the instances of the class.</p>
<p>Finally, <code>cacheAsBitmap</code> method allows me to render the Display Objects as bitmaps rather than vectors. You may say &#8220;just use a PNG image then&#8221;, and you&#8217;re right, but I wanted to keep the code as much similar to the original as I can.</p>
<p>This is the final example of the app working on my Iphone4:</p>
<p><iframe width="640" height="360" src="http://www.youtube.com/embed/zeOleAzv6K0" frameborder="0" allowfullscreen></iframe></p>
<p>It works quite well although I am considering using a sequence of dots rather than a thin line, I will keep you updated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2011/12/21/iphone-string-avoider-prototype-with-adobe-flash-professional-cs5-5/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 10/18 queries in 0.009 seconds using disk: basic

Served from: www.emanueleferonato.com @ 2012-02-08 20:03:10 -->
