<?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>blog.sokay.net</title>
	<atom:link href="http://blog.sokay.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sokay.net</link>
	<description>flash game development discussion</description>
	<lastBuildDate>Wed, 15 May 2013 07:38:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Flash Animation in Unity with LWF</title>
		<link>http://blog.sokay.net/2013/05/13/flash-animation-in-unity-with-lwf/</link>
		<comments>http://blog.sokay.net/2013/05/13/flash-animation-in-unity-with-lwf/#comments</comments>
		<pubDate>Mon, 13 May 2013 11:02:38 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[sprites]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1906</guid>
		<description><![CDATA[Since using Unity, I&#8217;ve been trying to replicate a pipeline that&#8217;s similar to Flash. Being able to use Flash&#8217;s environment for hand-polished 2d animation just can&#8217;t be beat, unless you count custom developed tools. LWF from GREE shows promise in allowing you to bring your Flash animation into Unity, but there is some work involved [...]]]></description>
				<content:encoded><![CDATA[<p>Since using Unity, I&#8217;ve been trying to replicate a pipeline that&#8217;s similar to Flash. Being able to use Flash&#8217;s environment for hand-polished 2d animation just can&#8217;t be beat, unless you count custom developed tools. <a href="http://gree.github.io/lwf/" target="_blank">LWF from GREE</a> shows promise in allowing you to bring your Flash animation into Unity, but there is some work involved in getting it to work!</p>
<p style="text-align: center;"><a href="http://blog.sokay.net/stuff/SokayTutLWF/" target="_blank"><img class="size-full wp-image-1910 aligncenter" alt="donuts_lwf" src="http://blog.sokay.net/wp-content/uploads/2013/05/donuts_lwf.png" width="477" height="273" />Demo made with LWF in Unity.</a></p>
<p>With the mobile version of <a href="http://www.donutget.com" target="_blank">DONUT GET!</a>, I tried <a href="http://blog.sokay.net/2012/11/05/2d-sprite-animation-in-unity/" target="_blank">a homemade Sprite Animation approach</a>. This worked reasonably for the requirements of the port but it was more trouble than anticipated given the size of the texture sheets needed for so many frames of animation. Sprite sheets ate up RAM like nobody&#8217;s business and easily crashed lower-end devices.</p>
<p>Late last year <a href="http://www.gamasutra.com/view/news/179683/Gree_releases_open_source_tool_for_bringing_Flash_animation_to_Unity_HTML5.php" target="_blank">GREE announced a godsend</a>, LWF. It&#8217;s an Open Source tool to export Flash animation from SWF&#8217;s into Unity or HTML5. This was around the time I released DONUT GET! on mobile (which was GREE integrated) and I was excited to try it out. Unfortunately, the first release required you to compile it yourself and the only info I could find was in Japanese. Later on I found out that <a href="http://forum.unity3d.com/threads/158771-LWF-an-open-source-tool-for-bringing-Flash-animation-to-Unity-and-HTML5" target="_blank">GREE posted more information</a> and a super helpful <a href="http://www.youtube.com/watch?feature=player_embedded&amp;v=K7awPpMplIk" target="_blank">video walkthrough</a> on the Unity forums.<br />
<span id="more-1906"></span></p>
<h2>FLA Setup</h2>
<p>A few months ago I tried to make a demo bringing animation from DONUT GET! into Unity with LWF. I quickly found out that there are a whole bunch of gotchas.</p>
<ul>
<li>Set FLA to Flash Player 7, ActionScript 1.0</li>
<li>Extremely limited ActionScript. I believe just gotoAndPlay/Stop level commands will work and FSCommands can be used to shoot events back to Unity. I haven&#8217;t tried this stuff!</li>
<li>No vector graphics. Vector graphics can be exported as images and re-imported as images.</li>
<li>MovieClips must only contain 1 image. Appears to fail with multiple images.</li>
<li>MovieClips can contain multiple nested MovieClips, just not in combinations with images it seems.</li>
<li>Alpha works properly.</li>
<li>All images must have Lossless (GIF/PNG) Compression. JPEG Compression will throw error.</li>
<li>For examples, (Limited) Demo FLA&#8217;s available at: <a href="https://github.com/gree/lwf-demo" target="_blank">https://github.com/gree/lwf-demo</a></li>
</ul>
<h2>Getting Started</h2>
<p>GREE&#8217;s video gives a great rundown of how it works, check it here: <a href="http://www.youtube.com/watch?v=K7awPpMplIk" target="_blank">http://www.youtube.com/watch?v=K7awPpMplIk</a><a href="http://www.youtube.com/watch?feature=player_embedded&amp;v=K7awPpMplIk"><br />
</a></p>
<p>Download LWF here: <a href="http://gree.github.io/lwf/">http://gree.github.io/lwf/</a></p>
<p>You&#8217;ll find the unitypackage in the LWF zip file in the path &#8220;csharp/unity/dist/lwf.unitypackage&#8221;. Import this into your Unity project to access the LWF library.</p>
<p><em>LWFS</em>, with an &#8216;S&#8217;, is a program that will run in the background on your computer and automatically converts SWF&#8217;s into LWF format. It creates a folder on your desktop called &#8220;LWFS_work&#8221; and &#8220;LWFS_work_output&#8221;. In the &#8220;LWFS_work_output/unity&#8221; folder, you&#8217;ll find a folder that was created with the same name of the SWFs you convert.</p>
<p>Copy that folder into the &#8220;Assets/Resources&#8221; folder of your project. If you don&#8217;t have a &#8220;Resources&#8221; folder, create one.</p>
<p>&nbsp;</p>
<h2>How it Works</h2>
<p>I&#8217;m not gonna act like I&#8217;ve sorted through and analyzed all the code to understand how it works. From what I understand though, it rips apart all of the MovieClips and grabs the images they contain. The .bytes file seems to carry all the information about the depth sorting, movement, timing, etc.</p>
<p style="text-align: center;"><img src="http://blog.sokay.net/wp-content/uploads/2013/05/lwf_pieces.png" alt="lwf_pieces" width="531" height="373" class="alignnone size-full wp-image-1922" /><br />
Here&#8217;s what LWFS spits out.</p>
<p>Documentation is a bit limited so I&#8217;ve been trying to figure it out as I go along with trial and error.</p>
<h2>Some Sample Code</h2>
<p>I made a little wrapper class to make it a bit easier to use. You can set the texturePrefix and lwfName strings in the editor. These are paths to the LWF files.</p>
<p><strong>lwfName</strong> &#8211; This is the path in the &#8220;Resources&#8221; folder to the .bytes file. In my case it was &#8220;lwf/demo_sprite_walk.swf/demo_sprite_walk&#8221; because I have all of my animations in a &#8220;lwf&#8221; folder within &#8220;Resources.&#8221;</p>
<p><strong>texturePrefix</strong> &#8211; This is a path to the folder containing the images. In my case, it was &#8220;lwf/demo_sprite_walk.swf/&#8221;. Just remove the &#8220;lwf/&#8221; if you&#8217;re not putting them in an &#8220;lwf&#8221; folder.</p>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">UnityEngine</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> SimpleLWFObject <span style="color: #008000;">:</span> LWFObject <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> texturePrefix<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Use this for initialization</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">void</span> Start <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Load<span style="color: #008000;">&#40;</span>lwfName, texturePrefix<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> PlayAnimation<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> name<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Debug<span style="color: #008000;">.</span><span style="color: #0000FF;">Log</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Play LWF Animation: &quot;</span> <span style="color: #008000;">+</span> name<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">switch</span><span style="color: #008000;">&#40;</span>name<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;walk_right&quot;</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StopMovie<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;guy_left&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PlayMovie<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;guy_right&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetAlphaMovie<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;guy_left&quot;</span>,<span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetAlphaMovie<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;guy_right&quot;</span>,1f<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//SetVisibleMovie(&quot;guy_right&quot;, true);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//SetVisibleMovie(&quot;guy_left&quot;, false);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;walk_left&quot;</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StopMovie<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;guy_right&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PlayMovie<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;guy_left&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetAlphaMovie<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;guy_left&quot;</span>,1f<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetAlphaMovie<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;guy_right&quot;</span>,<span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//SetVisibleMovie(&quot;guy_left&quot;, true);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//SetVisibleMovie(&quot;guy_right&quot;, false);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>And from there, I can call the animation I want with something like &#8220;lwfObject.PlayAnimation(&#8220;walk_left&#8221;);&#8221;</p>
<p>In the FLA I setup, it contains two MovieClips with the instance names &#8220;guy_left&#8221; and &#8220;guy_right&#8221;. They&#8217;re both the same MovieClip, one&#8217;s just flipped horizontally to face left. This was a quick and dirty example to get an idea of how to go about bringing some lightweight interactive character animation into Unity.</p>
<p>Please note that I&#8217;m extending LWFObject for this class. I just couldn&#8217;t get LWFPlayer to work properly for me. For some reason when I tried it, it would just use one image for all of the different body parts.</p>
<p>The most major problem I found was with the depth sorting. When using a perspective camera, you&#8217;ll encounter Z-fighting depending on the viewing angle. This can be a problem with character animation when the arms are popping through the head or the legs are appearing behind the body. Also because of this sorting, I couldn&#8217;t just flip the walk animation around on the Y axis because the sort-order would be reversed. So to remedy it, I had a &#8220;guy_left&#8221; and &#8220;guy_right&#8221; MovieClip in the FLA. &#8220;guy_left&#8221; starts with an alpha of 0, which is why you don&#8217;t see it on start.</p>
<p>To remedy the sorting issue, I used an orthographic camera. It works, but things are no fun without perspective! <img src='http://blog.sokay.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Also, I found a way to get around this sorting issue. You can change the camera&#8217;s sorting method like so:</p>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gameObject<span style="color: #008000;">.</span><span style="color: #0000FF;">camera</span><span style="color: #008000;">.</span><span style="color: #0000FF;">transparencySortMode</span> <span style="color: #008000;">=</span> TransparencySortMode<span style="color: #008000;">.</span><span style="color: #0000FF;">Orthographic</span><span style="color: #008000;">;</span></div></td></tr></tbody></table></div>
<p>This seems to resolve sorting issues with a perspective camera.</p>
<p>Animations using this technique use a fraction of memory as my Sprite Sheet method. I&#8217;m planning on using this technique for animated scenes in our next game <a href="http://www.thecrazyprogram.com" target="_blank">The Crazy Program</a> to see how they work out.</p>
<p>I have to thank GREE for their open source tools! LWF is great and I&#8217;m looking forward to checking out their <a href="https://github.com/gree/unity-webview" target="_blank">Unity WebView</a> as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2013/05/13/flash-animation-in-unity-with-lwf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DONUT GET! OUYA Download Statistics</title>
		<link>http://blog.sokay.net/2013/04/26/donut-get-ouya-download-statistics/</link>
		<comments>http://blog.sokay.net/2013/04/26/donut-get-ouya-download-statistics/#comments</comments>
		<pubDate>Fri, 26 Apr 2013 17:03:31 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[Donut Get!]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Sokay Development]]></category>
		<category><![CDATA[Sokay Games]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[donut get]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[ouya]]></category>
		<category><![CDATA[sales]]></category>
		<category><![CDATA[stats]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1888</guid>
		<description><![CDATA[I ported DONUT GET! to OUYA with the hope of it being a OUYA launch title. I anticipated that it would at least help bring a bit more attention to DONUT GET!, especially since it didn&#8217;t get as much coverage as expected. Fortunately DONUT GET! was listed as one of the 104 OUYA launch titles, [...]]]></description>
				<content:encoded><![CDATA[<p>I ported <a href="http://www.donutget.com" target="_blank">DONUT GET!</a> to OUYA with the hope of it being a OUYA launch title. I anticipated that it would at least help bring a bit more attention to DONUT GET!, especially since it didn&#8217;t get as much coverage as expected. Fortunately DONUT GET! was listed as one of the 104 OUYA launch titles, and mentioned on sites like <a href="http://www.destructoid.com/behold-ouya-s-launch-lineup-of-104-titles-250570.phtml" target="_blank">Destructoid</a>.</p>
<p>We&#8217;ve made our download stats available for DONUT GET! on OUYA. It&#8217;s a totally free game &#8212; there&#8217;s no in-app purchases.</p>
<p style="text-align: center;"><a href="http://www.donutget.com/ouya-stats/" target="_blank"><img class="size-full wp-image-1890 aligncenter" alt="donutget_ouya_stats" src="http://blog.sokay.net/wp-content/uploads/2013/04/donutget_ouya_stats.jpg" width="450" height="266" /></a><br />
<em> Our DONUT GET! OUYA Download stats are available here: <a href="http://www.donutget.com/ouya-stats/" target="_blank">http://www.donutget.com/ouya-stats/</a></em></p>
<p>&nbsp;</p>
<p>A large problem within the OUYA community is that the company is slowly trickling out the ~60,000 Kickstarter units. For developers it&#8217;s a bit unsettling with the low download numbers, and the myriad of other software problems we&#8217;re dealing with.<span id="more-1888"></span></p>
<p style="text-align: center;"><a href="http://ouyaforum.com/showthread.php?2262-Kickstarter-Update-23-Box-It-Stamp-It-Ship-It" target="_blank"><img class="alignnone size-full wp-image-1889" alt="ouya_shipments_chart" src="http://blog.sokay.net/wp-content/uploads/2013/04/ouya_shipments_chart.png" width="577" height="353" /><br />
</a><em>Here&#8217;s the vaguish chart the OUYA Team released to appease the backers.</em></p>
<p>Guessing from the chart, about 20% of the 60,000 backers received units by now. Which amounts to about 12,000 units. With DONUT GET!&#8217;s 420 downloads, this amounts to about 3.5% of the total userbase. Is that good? It&#8217;s hard to say, but if that rate is extrapolated for all 60,000 users that&#8217;d be about 2,100 downloads which isn&#8217;t too bad to me. I believe it took us longer to get 2,000 downloads on the Google Play.</p>
<h2>What&#8217;s Next?</h2>
<p>I wanted to port a &#8220;lean&#8221; version of DONUT GET! to test waters for the marketplace. What was required for development? What was the approval process like? Will anybody even download it?</p>
<p>For this reason, the port was minimal. Essentially the mobile version with mobile specific stuff ripped out (ads, GREE integration, etc.). I made some &#8216;quick &amp; dirty&#8217; tweaks to UI to make it navigable with an OUYA controller.</p>
<p>The port took about 2 1/2 days. I used the Unity exporter included in <a href="https://devs.ouya.tv" target="_blank">their SDK</a>. I don&#8217;t actually have an OUYA to test  on, but used an <a href="http://www.amazon.com/iMito-MX1-Bluetooth-Aluminium-Dissipation/dp/B00AIIO3DO" target="_blank">Android computer</a> that worked similarly. I wasn&#8217;t able to get the OUYA SDK fully working on it though.</p>
<p>I figured if there was enough interest I can go back to the game and add new stages and some form of in-app purchase to see if it generates any revenue. We intend to release our upcoming game, <a href="http://www.thecrazyprogram.com" target="_blank">The Crazy Program</a> on OUYA for like a 1.1 release once we get it working with a controller. It&#8217;s primarily designed for touch screens.</p>
<h2>More OUYA Stats</h2>
<p>Other developers have been sharing their stats in forum threads.</p>
<ul>
<li><a href="http://ouyaforum.com/showthread.php?2200-OUYA-Sales-Downloads-Stats-from-Developers" target="_blank"><span style="line-height: 13px;">ouyaforum.com &#8211; OUYA Sales/Downloads Stats from Developers? Thread</span></a></li>
<li><a href="http://forums.ouya.tv/discussion/1196/salesdownloads" target="_blank">OUYA Developer Forums &#8211; Sales/Downloads Thread</a></li>
</ul>
<h2>Download DONUT GET! on OUYA</h2>
<p>OUYA doesn&#8217;t yet have a way to link directly to your app listing, but another site is scraping their data and building a catalog of their own.</p>
<ul>
<li><a href="http://www.totalouya.com/apps-and-games/46-donut-get/" target="_blank">DONUT GET! OUYA Listing</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2013/04/26/donut-get-ouya-download-statistics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unity LA Meetup &#8211; Meet OUYA</title>
		<link>http://blog.sokay.net/2013/01/23/unity-la-meetup-meet-ouya/</link>
		<comments>http://blog.sokay.net/2013/01/23/unity-la-meetup-meet-ouya/#comments</comments>
		<pubDate>Thu, 24 Jan 2013 05:44:11 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[Coolio]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[Video Games]]></category>
		<category><![CDATA[devkit]]></category>
		<category><![CDATA[Los Angeles]]></category>
		<category><![CDATA[meetup]]></category>
		<category><![CDATA[ouya]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1873</guid>
		<description><![CDATA[A few weeks ago I attended the Unity LA Meetup OUYA talk. There was a talk and lengthy Q&#38;A with some people from OUYA. The event cleared up a lot of questions I had about the project. Representing OUYA on stage was Raffi Bagdasarian, who left product development at Sony to join the OUYA team. He [...]]]></description>
				<content:encoded><![CDATA[<p>A few weeks ago I attended the <a href="http://www.meetup.com/LAUnity3D/events/95579942/" target="_blank">Unity LA Meetup OUYA talk</a>. There was a talk and lengthy Q&amp;A with some people from OUYA. The event cleared up a lot of questions I had about the project.</p>
<p>Representing OUYA on stage was Raffi Bagdasarian, who left product development at Sony to join the OUYA team. He explained that OUYA was originally known as Boxer8. He also brought on the Unity plug-in developer Tim over Skype to talk about some technical aspects of the Unity integration.</p>
<p>Developers can sign up for the OUYA developer program for free at <a href="http://devs.ouya.tv" target="_blank">http://devs.ouya.tv</a> . There you can download the SDK, view the actively updating documentation, and lurk in the forums. They&#8217;re still ironing out the upload process so you&#8217;re not able to upload to the OUYA online store yet.</p>
<p style="text-align: center;"><img class="size-full wp-image-1874 aligncenter" alt="Ouya Unity LA Meetup" src="http://blog.sokay.net/wp-content/uploads/2013/01/ouya_meetup.jpg" width="450" height="336" /><em>Unity LA Meetup (photo courtesy of the Meetup page!)</em></p>
<p>And now some bullet points:</p>
<ul>
<li>The console will be running Android 4.1 Jellybean.</li>
<li>The SDK consists of in-app purchase and controller APIs.</li>
<li>Games are required to be free to play, but features can be unlocked with in-app purchases. This apparently is also a method to curb piracy.</li>
<li>There&#8217;s the typical 70% (developer) / 30% (provider) split.</li>
<li>They&#8217;re focusing on app discovery for the OUYA store, aiming to organize the shops by more detailed metrics than &#8220;highest grossing&#8221; or &#8220;most downloads.&#8221; Using metrics such as most played, longest played, etc.</li>
<li>Approval process will have guidelines &#8212; not total free for all. Initially they&#8217;ll be reviewing every game manually. Eventually they&#8217;ll work peer review into the process, similar to Xbox Indie Games.</li>
<li>As far as the style guide, they were working on prepping an official one. But in the meantime, feel free to use OUYA name and branding as long as you&#8217;re not presenting yourself as sanctioned officially by OUYA. Also, it&#8217;s supposed to be spelled in all caps! haha <img src='http://blog.sokay.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>There won&#8217;t be a content rating system like ESRB, but they&#8217;re planning something similar to Google Play.</li>
<li>Online matchmaking, achievements, Xbox Live features, etc. Not at launch, but planned for eventual release. Until then, feel free to roll your own systems.</li>
</ul>
<p><em>More Stuff, Etc&#8230;</em></p>
<ul>
<li>With only 8 gigs of built in storage, game sizes should be developed with that in mind. They&#8217;re working out what the hard limits should be as some games currently in development are a few gigs.</li>
<li>They recommended tools like the Unity asset store&#8217;s APK Splitter, to give a quick initial download from the store and load in assets as needed during the game.</li>
<li>They&#8217;re looking into cloud storage. At the time they were apparently debating it.</li>
<li>Looking into system level integration of Facebook and Twitter. I&#8217;m assuming for viral sharing games, and another metric for surfacing content.</li>
<li>Developers won&#8217;t be restricted from accessing websites from within games, should be able to pull any kind of data.</li>
<li>No access to Android Google Play store from within OUYA.</li>
<li>They&#8217;re open to accepting apps that are outside of games, like video players, etc.</li>
<li>No vibration with controller, mouse + keyboard are allowed.</li>
<li>They&#8217;ll have store analytics available to developers at launch, supposed to be better than Apple&#8217;s minimal dataset.</li>
<li>Piracy &#8211; since every game is free to play, they&#8217;re relying on in-app purchases API calls to unlock things.</li>
</ul>
<p><span id="more-1873"></span></p>
<p>Before this talk I was a bit apprehensive about the OUYA. It wasn&#8217;t clear to me <em>how Android</em> it was. What kind of additional development you needed to do to get something running on it? How would Unity development work with it? And so on. Now that I&#8217;ve learned that you basically just need to:</p>
<ul>
<li>Develop your game at HDTV resolution</li>
<li>Make it work with a controller and implement their controller API</li>
<li>Implement in-app purchase and other required OUYA APIs</li>
<li>Test it on an OUYA or similar Android device</li>
</ul>
<p>What really changed my perspective was seeing the excitement for the console, with all the developers that showed up. I talked with the homie <a href="https://twitter.com/ray_barrera/">Ray</a>, who&#8217;s doing development on an OUYA game, and his enthusiasm inspired me. He showed me the light.</p>
<p>Since then I&#8217;ve looked into seeing how realistic it was to create my own OUYA devkit. I found videos online showing that it&#8217;s feasible to turn any Android device into an OUYA.</p>
<p>&nbsp;</p>
<p><iframe src="http://www.youtube-nocookie.com/embed/mwAegN5nUMA?rel=0" height="253" width="450" allowfullscreen="" frameborder="0"></iframe></p>
<p>&nbsp;</p>
<p>This seems pretty easy and who knows if it&#8217;ll be this easy with the final operating system. I&#8217;m still iffy about this conflict of the system being &#8220;open&#8221; but still &#8220;not-open.&#8221; I hope they keep it open!</p>
<p>I&#8217;m looking forward to the March release!</p>
<p>If you&#8217;re a Unity developer in the Los Angeles area, be sure to check out the <a href="http://www.meetup.com/LAUnity3D/" target="_blank">Unity LA User Group on Meetup</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2013/01/23/unity-la-meetup-meet-ouya/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Making a Game with CSS3 3D</title>
		<link>http://blog.sokay.net/2012/11/16/making-a-game-with-css3-3d/</link>
		<comments>http://blog.sokay.net/2012/11/16/making-a-game-with-css3-3d/#comments</comments>
		<pubDate>Sat, 17 Nov 2012 02:30:52 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[sprite3d]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1824</guid>
		<description><![CDATA[The Demo Here&#8217;s a CSS3 demo of the Donut Get! background. Use your mouse to adjust the perspective of the scene. I&#8217;ve been messing around with CSS3&#8242;s 3D Transform ability recently. I was looking for a way to achieve some primitive 3D visuals strictly with HTML. I wanted something that would also run on phones [...]]]></description>
				<content:encoded><![CDATA[<h2>The Demo</h2>
<p>Here&#8217;s a CSS3 demo of the <a href="http://www.donutget.com" target="_blank">Donut Get!</a> background.</p>
<p><iframe src="http://blog.sokay.net/stuff/donutgetCSS3/" name="donutgetCSS3Frame" width="480" height="300" frameborder="0" allowtransparency="true" scrolling="no"></iframe></p>
<p>Use your mouse to adjust the perspective of the scene.</p>
<p>I&#8217;ve been messing around with <a href="http://www.w3schools.com/css3/css3_3dtransforms.asp" target="_blank"><strong>CSS3&#8242;s 3D Transform</strong></a> ability recently. I was looking for a way to achieve some primitive 3D visuals strictly with HTML. I wanted something that would also run on phones and tablets.<br />
<span id="more-1824"></span></p>
<h2>The Alternatives</h2>
<p>WebGL, although powerful, didn&#8217;t seem to be a good option since it&#8217;s not really an accepted standard at the this point, as much as enthusiasts would like it to be. I considered messing around <a href="http://mrdoob.github.com/three.js/" target="_blank">with three.js</a> as it has canvas functionality that could function as a fallback if WebGL wasn&#8217;t available. Before trying that out though, I discovered CSS3&#8242;s 3D Transform abilities and how easy it was to work with.</p>
<p>I came across some demos with <a href="http://minimal.be/lab/Sprite3D/" target="_blank">Sprite3D.js</a> that ran well on my iPad so I thought I&#8217;d look into CSS3 stuff. I discovered that Sprite3D was just a simple wrapper for CSS3 transform so I just decided to jump into it for myself.</p>
<h2>The Setup</h2>
<p>The beauty of this is that you can setup all your game elements as divs. I never thought of using divs as game objects until the homie <a href="http://activetheory.net" target="_blank">Michael Anthony</a> paradigm shifted my perspective a bit. Using javascript, we can update the position of the player, enemies, etc. using CSS properties like &#8216;left&#8217; or &#8216;top&#8217; or in the case of this demo, &#8216;translate3d.&#8217;</p>
<p>Here&#8217;s all the important HTML I used to setup the scene:</p>
<div class="codecolorer-container html4strict railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;SokayAppView&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;GameWorld&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;DonutGetSkyline&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;DonutGetMid&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;DonutGetShoppe&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;DonutGetBuildingLeftSide&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;DonutGetBuildingRightSide&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;DonutGetSidewalk&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;DonutGetBuildingLeft&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;DonutGetBuildingRight&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;GameBGSky&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span></div></td></tr></tbody></table></div>
<p>The &#8220;SokayAppView&#8221; and &#8220;GameWorld&#8221; elements are used to create a &#8220;frame&#8221; for the content to live in. In this example I set the dimensions to 480&#215;300 to fit within this blog, but you can easily set it to 100% or whatever you like. Each of the game elements are defined as divs within &#8220;GameWorld.&#8221;</p>
<p>The order I listed the divs is just to control the order the elements are displayed in. When using translate3d, the browser still uses the Z-index to control the display order unless you set the property to &#8220;transform-style: preserve-3d;&#8221;, which will make the objects display by their actual Z position in space.</p>
<h2>The CSS</h2>
<p>I&#8217;m using the &#8220;GameWorld&#8221; container to control the perspective of the scene. From my understanding, the settings you set in this parent element will affect all the children which are set to &#8220;<strong>preserve-3d</strong>.&#8221; Something like that&#8230; haha! Changing the &#8216;<strong>perspective</strong>&#8216; property will adjust the perspective of the scene, similar to a focal length. Using &#8216;<strong>perspective-origin</strong>&#8216;, you can control where the vanishing point is within the scene, it starts close to the center and is adjusted with the mouse movement.</p>
<div class="codecolorer-container css railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666ff;">.GameWorld</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">60%</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">50%</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; transform-style<span style="color: #00AA00;">:</span> preserve-3d<span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; transform-style<span style="color: #00AA00;">:</span> flat<span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; -webkit-perspective<span style="color: #00AA00;">:</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; perspective<span style="color: #00AA00;">:</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; -webkit-perspective-origin<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-80px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; perspective-origin<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-80px</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<p>The following example shows how I&#8217;m using CSS to create an image for the Donut Shoppe. I set size of the div to be at least the width and height of the image, then set the background image to be that of the shoppe.</p>
<div class="codecolorer-container css railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666ff;">.DonutGetShoppe</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">215px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">../images/shoppe.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; transform-style<span style="color: #00AA00;">:</span> preserve-3d<span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; transform-style<span style="color: #00AA00;">:</span> flat<span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; -moz-transform<span style="color: #00AA00;">:</span> translate3d<span style="color: #00AA00;">&#40;</span><span style="color: #933;">-150px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">-150px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">-100px</span><span style="color: #00AA00;">&#41;</span> rotateX<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span> rotateY<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span> rotateZ<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; -webkit-transform<span style="color: #00AA00;">:</span> translate3d<span style="color: #00AA00;">&#40;</span><span style="color: #933;">-150px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">-150px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">-100px</span><span style="color: #00AA00;">&#41;</span> rotateX<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span> rotateY<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span> rotateZ<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; -webkit-transform-origin<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; -moz-transform-origin<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<p>I painstakingly setup the positions of the walls and layers by eyeing them. I adjust the Z position to force perspective in the view, and adjust the scale to makeup for the size differences. You can use &#8220;transform-origin&#8221; to control where the pivot point of a object will be, in this case when I&#8217;m rotating the building side walls.</p>
<h2>Make it Move!</h2>
<p>So now that we&#8217;ve got a scene setup, here&#8217;s how we can add a little bit of motion for a little bit of effort.</p>
<p>In the javascript, I&#8217;m using jquery to wait for a document complete event to set a mousemove and mouseout event for the scene. On mousemove, we&#8217;ll set the &#8216;active&#8217; variable to true so the perspective will be updated. As well as set the perspectivePos array to a number based on the mouse position. On mouseout, we&#8217;ll simply set &#8216;active&#8217; to false.</p>
<div class="codecolorer-container javascript railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.SokayAppView'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mousemove</span><span style="color: #009900;">&#40;</span>mouseMoveEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">function</span> mouseMoveEvent<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//console.log(&quot;e: &quot; + e + &quot; , x:&quot; + e.clientX + &quot; ,y: &quot; + e.clientY);</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> _xmouse <span style="color: #339933;">=</span> e.<span style="color: #660066;">clientX</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> _ymouse <span style="color: #339933;">=</span> e.<span style="color: #660066;">clientY</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; perspectivePos<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> _xmouse <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>GAME_WIDTH<span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; perspectivePos<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">80</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>_ymouse <span style="color: #339933;">/</span> GAME_HEIGHT<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">80</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// enable the update on mouse out</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>active<span style="color: #009900;">&#41;</span> active <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Then I take the perspective variables and update the CSS for the &#8220;GameWorld.&#8221;</p>
<div class="codecolorer-container javascript railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> act<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>active<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// update the perspective-origin css property</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.GameWorld'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">cssText</span> <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;perspective-origin:&quot;</span> <span style="color: #339933;">+</span> perspectivePos<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px &quot;</span> <span style="color: #339933;">+</span> perspectivePos<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px;&quot;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;-webkit-perspective-origin:&quot;</span> <span style="color: #339933;">+</span> perspectivePos<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px &quot;</span> <span style="color: #339933;">+</span> perspectivePos<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<h2>That&#8217;s it!</h2>
<p>This might leave some questions but I&#8217;m sure you can figure the rest out from here! So have at it! <img src='http://blog.sokay.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<ul>
<li><a href="http://blog.sokay.net/stuff/donutgetCSS3/" target="_blank">View the HTML page, to get a closer look.</a></li>
<li><a href="http://blog.sokay.net/stuff/donutgetCSS3/assets/css/SokayDonutGet.css" target="_blank">SokayDonutGet.css</a></li>
<li><a href="http://blog.sokay.net/stuff/donutgetCSS3/assets/js/SokayDonutGet.js" target="_blank">SokayDonutGet.js</a></li>
</ul>
<p>There are still some issues I&#8217;m trying to work out with being able to rotate objects and create a more believable environment. There&#8217;s lot of quirks to the way I setup things here. I may give Sprite3D.js a shot to see if it solves any of these issues.</p>
<p>I&#8217;m still warming up to these HTML5 technologies. It&#8217;s amazing how far things have come since like Internet Explorer 3.0.</p>
<h2>Get The APP!</h2>
<p><a href="http://www.donutget.com" target="_blank">DONUT GET!</a> is a Mobile and Flash game created by the team at Sokay.net. The mobile version was developed in Unity, check out <a href="http://blog.sokay.net/2012/11/05/2d-sprite-animation-in-unity/" target="_blank">a tutorial how I create its sprite animation system</a>.<br />
<center><br />
<a href="http://www.donutget.com/download/iphone/"><img class="aligncenter size-full wp-image-1805" title="donutget_gree_icon" src="http://blog.sokay.net/wp-content/uploads/2012/11/donutget_gree_icon.png" alt="" width="125" height="125" /></a></center></p>
<ul>
<li>For iPhone &amp; iPad at <a href="http://www.donutget.com/download/iphone/" target="_blank">http://www.donutget.com/download/iphone/</a></li>
<li>For Android at <a href="http://www.donutget.com/download/android/" target="_blank">http://www.donutget.com/download/android/</a></li>
<li>For the web at <a href="http://www.sokay.net/play/donut-get" target="_blank">http://www.sokay.net/play/donut-get</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2012/11/16/making-a-game-with-css3-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2D Sprite Animation in Unity</title>
		<link>http://blog.sokay.net/2012/11/05/2d-sprite-animation-in-unity/</link>
		<comments>http://blog.sokay.net/2012/11/05/2d-sprite-animation-in-unity/#comments</comments>
		<pubDate>Mon, 05 Nov 2012 22:01:11 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[2d]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[spritesheet]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[unity3d]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1781</guid>
		<description><![CDATA[&#160; We recently released Donut Get! on iPhone and Android. It was originally developed in Flash and we made the mobile ports in Unity. One of the challenges of porting was figuring out how to bring the game&#8217;s Flash animation into Unity. Here&#8217;s the &#8220;quick &#8216;n dirty&#8221; solution I came up with. Exporting Animation Spritesheet [...]]]></description>
				<content:encoded><![CDATA[<p><center><br />
<a href="http://www.donutget.com/download/iphone/" target="_blank"><img class="size-full wp-image-1810 aligncenter" title="donutget_android_screen_02" src="http://blog.sokay.net/wp-content/uploads/2012/11/donutget_android_screen_02.jpg" alt="" width="234" height="400" /></a><br />
<a href="http://www.donutget.com/download/iphone/" target="_blank"><img title="app_store_itunes_sm" src="http://blog.sokay.net/wp-content/uploads/2012/11/app_store_itunes_sm.png" alt="" width="131" height="45" /></a><a href="http://www.donutget.com/download/android/" target="_blank"><img title="android_app_on_play_logo_small" src="http://blog.sokay.net/wp-content/uploads/2012/11/android_app_on_play_logo_small.png" alt="" width="129" height="45" /></a></center>&nbsp;</p>
<p>We recently released Donut Get! on iPhone and Android. It was originally developed in Flash and we made the mobile ports in Unity. One of the challenges of porting was figuring out how to bring the game&#8217;s Flash animation into Unity. Here&#8217;s the &#8220;quick &#8216;n dirty&#8221; solution I came up with.<br />
<span id="more-1781"></span></p>
<h2>Exporting Animation Spritesheet from Flash</h2>
<p>The first step was figuring out a good way to export the character animation from Flash. I needed a program that could export a sheet at a uniform size that would be in power of 2&#8242;s so it&#8217;ll work as a texture (256&#215;256, 512&#215;512, 1024&#215;1024, etc).</p>
<p>I ended up using <a href="http://www.bit-101.com/blog/?p=2939">Keith Peters&#8217; SWFSheet</a>, it loads a swf and allows you to an export a spritesheet from it. I created an FLA for each animation with the dimensions of 256&#215;256. I placed the cop Movieclip in the center, extended the timeline to the appropriate amount of frame and let &#8216;er rip!</p>
<p><img class="aligncenter size-full wp-image-1782" title="donutget_cop_spritesheet" src="http://blog.sokay.net/wp-content/uploads/2012/10/donutget_cop_spritesheet.png" alt="" width="500" height="500" /></p>
<p>The result is a sprite sheet image that looks like this. I exported it at 2048&#215;2048 but dropped it down to 1024&#215;1024 within Unity for its release.</p>
<p>&nbsp;</p>
<h2>The Fuzzy Textures Edges Removal</h2>
<p>You want to import your textures into Unity as PSDs, especially if there are alpha channels. Once imported, Unity can convert it to whatever type of texture you need with the texture properties panel. One problem I encountered early one was fuzzy white edges around the black outlines of the characters and backgrounds. I found a good trick to get around the problem on Unity Answers.</p>
<blockquote>
<ul>
<li>Download and install the Flaming Pear &#8220;<a href="http://www.flamingpear.com/download.html">Free Plugins</a>&#8221; pack (near the bottom of that list)</li>
<li>Open your PNG in photoshop.</li>
<li>Go to <strong>Select -&gt; Load Selection</strong> and click OK.</li>
<li>Go to <strong>Select -&gt; Save Selection</strong> and click OK. This will create a new alpha channel.</li>
<li>Now Deselect all (Ctrl-D or Cmd-D)</li>
<li>Select <strong>Filter -&gt; Flaming Pear -&gt; Solidify B</strong></li>
</ul>
</blockquote>
<p>I jacked this directly from the thread <a href="http://answers.unity3d.com/questions/10302/messy-alpha-problem-white-around-edges.html">here</a>. Also in my PSD I made a copy of the original, hid it, and applied the filter to the copy just in case I needed to revert back to the original. I did encounter issues with the alpha channel not working correctly sometimes, you may also have to delete the &#8220;Alpha&#8221; channel in the Photoshop Channels window to try again.</p>
<p>&nbsp;</p>
<h2>The Plane</h2>
<p>Unity is a 3d game engine. As such, I needed to create a 3d world for my 2d artwork. I used the textures on planes, like billboards. The problem with Unity&#8217;s built in plane is that it has too many subdivisions so it uses a lot of unnecessary polys. Fortunately on the Unity forums, I found a <a href="http://wiki.unity3d.com/index.php/CreatePlane">CreatePlane.cs script</a> that created a plane models for me. I tried to match up the proportions (width vs height) to a similar ratio as the images, so I didn&#8217;t have to scale the models for them to look correct in game. The result was something like this:</p>
<p style="text-align: center;"><img class="aligncenter" title="donutget_unity_editor_01" src="http://blog.sokay.net/wp-content/uploads/2012/10/donutget_unity_editor_01.jpg" alt="" width="517" height="436" /></p>
<p style="text-align: center;"><em>Yeah, it looks 2D but it&#8217;s all 3D mang!</em></p>
<p>&nbsp;</p>
<h2>The 2D Shader</h2>
<p>For DONUT GET! I needed a simple shader that didn&#8217;t have any lighting and also had transparency. I found some Unlit/Transparent shaders that worked well but I needed something that allowed double-sided polygons. I also needed a Color channel to use to apply tints and alpha fades. Here&#8217; what I came up with:</p>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Shader <span style="color: #666666;">&quot;Sokay/Simple Shader&quot;</span> <span style="color: #008000;">&#123;</span><br />
Properties <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; _Color <span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Tint (A = Opacity)&quot;</span>, Color<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1</span>,<span style="color: #FF0000;">1</span>,<span style="color: #FF0000;">1</span>,<span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span> <br />
&nbsp; &nbsp; _MainTex <span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Base (RGB) Trans (A)&quot;</span>, 2D<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;white&quot;</span> <span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
SubShader <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; Tags <span style="color: #008000;">&#123;</span><span style="color: #666666;">&quot;Queue&quot;</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;Transparent&quot;</span> <span style="color: #666666;">&quot;IgnoreProjector&quot;</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;True&quot;</span> <span style="color: #666666;">&quot;RenderType&quot;</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;Transparent&quot;</span><span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; LOD <span style="color: #FF0000;">100</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; ZWrite Off<br />
&nbsp; &nbsp; Blend SrcAlpha OneMinusSrcAlpha <br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// BACKFACING PASS</span><br />
&nbsp; &nbsp; Pass <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Lighting Off<br />
&nbsp; &nbsp; &nbsp; &nbsp; Cull Front<br />
&nbsp; &nbsp; &nbsp; &nbsp; ColorMaterial AmbientAndDiffuse<br />
&nbsp; &nbsp; &nbsp; &nbsp; SetTexture <span style="color: #008000;">&#91;</span>_MainTex<span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ConstantColor <span style="color: #008000;">&#91;</span>_Color<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; combine texture <span style="color: #008000;">*</span> constant<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; SetTexture <span style="color: #008000;">&#91;</span>_MainTex<span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; combine previous &nbsp;<span style="color: #008000;">*</span> primary<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// FRONT PASS</span><br />
&nbsp; &nbsp; Pass <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Lighting Off<br />
&nbsp; &nbsp; &nbsp; &nbsp; Cull Back<br />
&nbsp; &nbsp; &nbsp; &nbsp; ColorMaterial AmbientAndDiffuse<br />
&nbsp; &nbsp; &nbsp; &nbsp; SetTexture <span style="color: #008000;">&#91;</span>_MainTex<span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ConstantColor <span style="color: #008000;">&#91;</span>_Color<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; combine texture <span style="color: #008000;">*</span> constant<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; SetTexture <span style="color: #008000;">&#91;</span>_MainTex<span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; combine previous &nbsp;<span style="color: #008000;">*</span> primary<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>I wasn&#8217;t able to find a way to combine the front and back pass or use a single SetTexture command, although I believe there may be a way, possibly without using Shader language.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>The 2D Sprite Class</h2>
<p>Here is the class I created to run through the animation.</p>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">UnityEngine</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> SpriteAnimation <span style="color: #008000;">:</span> MonoBehaviour<br />
<span style="color: #008000;">&#123;</span><br />
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> initialized <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// don't run anything until initalized</span><br />
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> active <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// wait till active to do anything</span><br />
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> startedRoutine<span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> name <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Sprite Animation Name!&quot;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> Material sheetMaterial<span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> Texture sheetTexture<span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> isPlaying<span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> loop <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> completeFunction<span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> animationComplete <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// am I done playing yet?</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> _totalFrames<span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> _currentFrame <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">float</span> sheetWidth <span style="color: #008000;">=</span> 8f<span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">float</span> sheetHeight <span style="color: #008000;">=</span> 8f<span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> tileWidth<span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// width in pixels of individual tiles</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> tileHeight<span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// height in pixels of individual tiles</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">float</span> updateRate <span style="color: #008000;">=</span> 1f<span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// update rate in seconds or something</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">delegate</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnComplete<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// need to figure this delegate shiet out!</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Initialize<span style="color: #008000;">&#40;</span> Material _material , Texture _texture, <span style="color: #6666cc; font-weight: bold;">int</span> _totalAniFrames, <span style="color: #6666cc; font-weight: bold;">int</span> _tileWidth, <span style="color: #6666cc; font-weight: bold;">int</span> _tileHeight, <span style="color: #6666cc; font-weight: bold;">int</span> sheetWidth, <span style="color: #6666cc; font-weight: bold;">int</span> sheetHeight<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
initialized <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// get the party started!</span><br />
<br />
sheetMaterial <span style="color: #008000;">=</span> _material<span style="color: #008000;">;</span><br />
<br />
sheetTexture <span style="color: #008000;">=</span> _texture<span style="color: #008000;">;</span><br />
<br />
_totalFrames <span style="color: #008000;">=</span> _totalAniFrames<span style="color: #008000;">;</span><br />
<br />
sheetWidth <span style="color: #008000;">=</span> sheetWidth<span style="color: #008000;">;</span><br />
sheetHeight <span style="color: #008000;">=</span> sheetHeight<span style="color: #008000;">;</span><br />
<br />
tileWidth <span style="color: #008000;">=</span> _tileWidth<span style="color: #008000;">;</span><br />
tileHeight <span style="color: #008000;">=</span> _tileHeight<span style="color: #008000;">;</span><br />
<br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008080; font-style: italic;">// play an animation!</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Play<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
<span style="color: #008080; font-style: italic;">//Debug.Log(&quot;Play: &quot; + name);</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>active<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
active <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>isPlaying<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
isPlaying <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
<br />
animationComplete <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
<br />
sheetMaterial<span style="color: #008000;">.</span><span style="color: #0000FF;">mainTexture</span> <span style="color: #008000;">=</span> sheetTexture<span style="color: #008000;">;</span><br />
<br />
StartCoroutine<span style="color: #008000;">&#40;</span>Draw<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>startedRoutine<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
startedRoutine <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008080; font-style: italic;">// play an animation!</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Stop<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
<span style="color: #008080; font-style: italic;">//Debug.Log(&quot;Stop: &quot; + name);</span><br />
<br />
isPlaying <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
<br />
active <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
<br />
_currentFrame <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008080; font-style: italic;">// draw function</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> IEnumerator Draw<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">while</span><span style="color: #008000;">&#40;</span>isPlaying<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
<span style="color: #008080; font-style: italic;">//Debug.Log(&quot;Draw: &quot; + name);</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>initialized<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>active<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_currentFrame <span style="color: #008000;">&gt;</span> _totalFrames<span style="color: #008000;">&#41;</span> _currentFrame <span style="color: #008000;">-=</span> _totalFrames<span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_currentFrame <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span> _currentFrame <span style="color: #008000;">+=</span> _totalFrames<span style="color: #008000;">;</span> <span style="color: #6666cc; font-weight: bold;">int</span> _offsetX <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>_currentFrame <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">%</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span> sheetWidth<span style="color: #008000;">;</span> <span style="color: #6666cc; font-weight: bold;">int</span> _offsetY <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>_currentFrame <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">/</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span> sheetWidth<span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//Set the texture to the indicated offset sheetMaterial.mainTextureOffset = new Vector2 (_offsetX / sheetWidth, 1f - ((_offsetY + 1) / sheetHeight)); //Change the scale of the texture sheetMaterial.mainTextureScale = new Vector2 ( 1f / sheetWidth, 1f / sheetHeight); } } // next steps! _currentFrame++; if (_currentFrame &gt; _totalFrames) {</span><br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>loop<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
_currentFrame <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #008000;">&#123;</span><br />
_currentFrame <span style="color: #008000;">=</span> _totalFrames<span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// stop at the last frame</span><br />
<br />
animationComplete <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>completeFunction<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> CallCompleteFunction<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008080; font-style: italic;">// run this again!</span><br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>isPlaying<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<span style="color: #0600FF; font-weight: bold;">yield</span> <span style="color: #0600FF; font-weight: bold;">return</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> WaitForSeconds<span style="color: #008000;">&#40;</span>updateRate<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #008000;">&#123;</span><br />
<span style="color: #0600FF; font-weight: bold;">yield</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #6666cc; font-weight: bold;">void</span> Awake<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
sheetMaterial <span style="color: #008000;">=</span> renderer<span style="color: #008000;">.</span><span style="color: #0000FF;">material</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// modify this instance of the material</span><br />
<span style="color: #008080; font-style: italic;">//sheetMaterial = renderer.sharedMaterial; // modify all materials of this type</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008080; font-style: italic;">// Looks within this gameobject for a function to call</span><br />
<br />
<span style="color: #6666cc; font-weight: bold;">void</span> CallCompleteFunction <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<span style="color: #008080; font-style: italic;">//Debug.Log(&quot;CallCompleteFunction &gt;&gt;&gt; name: &quot; + name + &quot; , fn: &quot; + completeFunction);</span><br />
gameObject<span style="color: #008000;">.</span><span style="color: #0000FF;">SendMessage</span><span style="color: #008000;">&#40;</span>completeFunction, gameObject, SendMessageOptions<span style="color: #008000;">.</span><span style="color: #0000FF;">DontRequireReceiver</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> GetAnimationComplete<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<span style="color: #0600FF; font-weight: bold;">return</span> animationComplete<span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>And I used code like this within the Player class component to control the different SpriteAnimation components.</p>
<p>&nbsp;</p>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> PlayAnimation<span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">string</span> _name <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_name <span style="color: #008000;">!=</span> currentAnimationName<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
<span style="color: #008080; font-style: italic;">// find animation with the matching name!</span><br />
SpriteAnimation<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> sprites <span style="color: #008000;">=</span> gameObject<span style="color: #008000;">.</span><span style="color: #0000FF;">GetComponents</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #008080; font-style: italic;">// stop currently playing animation!</span><br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>currentAnimation<span style="color: #008000;">&#41;</span> currentAnimation<span style="color: #008000;">.</span><span style="color: #0000FF;">Stop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #008080; font-style: italic;">// save a reference</span><br />
<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>SpriteAnimation sprite <span style="color: #0600FF; font-weight: bold;">in</span> sprites<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>sprite<span style="color: #008000;">.</span><span style="color: #0000FF;">name</span> <span style="color: #008000;">==</span> _name<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
currentAnimation <span style="color: #008000;">=</span> sprite<span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008080; font-style: italic;">// play that shiet homie!</span><br />
currentAnimation<span style="color: #008000;">.</span><span style="color: #0000FF;">Play</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
currentAnimationName <span style="color: #008000;">=</span> _name<span style="color: #008000;">;</span><br />
<br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>The basic ideas I used to write this, I learned from <a href="http://www.rebelplanetcreations.com/downloads/Other/Tutorials/HowToMakeAGameInUnity3D.pdf">this tutorial</a>. I had used that idea of scaling the texture size to work out a system for creating tile-based stages with spritesheets. I adapted that class to make an animation class, and learn a bit about coroutines in Unity.</p>
<h2></h2>
<h2>The Warnings</h2>
<p>This may not be the perfect solution but its a start. This was all I needed for Donut Get! but there were some issues by using this exact same code.</p>
<p>This totally wastes texture space. Many animations in the game were only using 50-70% of the texture sheet size. These texture sheets can eat up a lot of mobile memory quickly, and that&#8217;ll crash older phones and tablets easily, so you only want to use as much as you need. Ideally, this code would allow multiple animations per sheet, allowing you to select which tile will be the start of the animation.</p>
<p>There may be other bugs or errors I didn&#8217;t encounter for this game, if you&#8217;ve got suggestions I&#8217;m down to listen! <img src='http://blog.sokay.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<h2>Play DONUT GET!</h2>
<p>Now that you&#8217;ve seen the shader, play the game!</p>
<p><center><br />
<a href="http://www.donutget.com/download/iphone/"><img class="aligncenter size-full wp-image-1805" title="donutget_gree_icon" src="http://blog.sokay.net/wp-content/uploads/2012/11/donutget_gree_icon.png" alt="" width="125" height="125" /></a></center></p>
<ul>
<li>For iPhone &amp; iPad at <a href="http://www.donutget.com/download/iphone/" target="_blank">http://www.donutget.com/download/iphone/</a></li>
<li>For Android at <a href="http://www.donutget.com/download/android/" target="_blank">http://www.donutget.com/download/android/</a></li>
<li>For the web at <a href="http://www.sokay.net/play/donut-get" target="_blank">http://www.sokay.net/play/donut-get</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2012/11/05/2d-sprite-animation-in-unity/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>DONUT GET! Now Available for iPhone, iPad and Android!</title>
		<link>http://blog.sokay.net/2012/10/29/donut-get-now-available-for-iphone-ipad-and-android/</link>
		<comments>http://blog.sokay.net/2012/10/29/donut-get-now-available-for-iphone-ipad-and-android/#comments</comments>
		<pubDate>Mon, 29 Oct 2012 16:28:36 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[Donut Get!]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Sokay Development]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1773</guid>
		<description><![CDATA[[ PRESS RELEASE ALSO AVAILABLE HERE ] Los Angeles, California &#8211; Oct. 29, 2012 &#8211; Sokay.net is proud to announce that DONUT GET! is now available for iPhone, iPad, Android, and web browsers. DONUT GET! is a game about a cop eating donuts raining from the sky. Everyone knows police officers fantasize about the burning [...]]]></description>
				<content:encoded><![CDATA[<p style="text-align: center;">[ <a href="http://www.donutget.com/press/" target="_blank">PRESS RELEASE ALSO AVAILABLE HERE</a> ]</p>
<p style="text-align: center;"><a href="http://donutget.com/download/iphone" target="_blank"><img class="size-full wp-image-1774 aligncenter" title="DonutGet_web_01" src="http://blog.sokay.net/wp-content/uploads/2012/10/DonutGet_web_01.png" alt="" width="379" height="499" /></a></p>
<p>Los Angeles, California &#8211; Oct. 29, 2012 &#8211; Sokay.net is proud to announce that <strong>DONUT GET</strong>! is now available for iPhone, iPad, Android, and web browsers. <strong>DONUT GET!</strong> is a game about a cop eating donuts raining from the sky.</p>
<p>Everyone knows police officers fantasize about the burning of Donut Shops, and Officer Brown is no exception. With donuts bursting in air, there&#8217;s proof in the night that Officer Brown will be there. You assume duty as our rotund hero crosses the thin blue line with sweet dreams of round treats bouncing behind his eyes&#8211;plenty o&#8217; donuts to get.</p>
<p>The web-based Flash version is 3 games in 1: driving, fighting and donut getting. The player&#8217;s actions change the game itself and multiple cinematic endings are available.</p>
<p>The mobile and tablet versions of <strong>DONUT GET!</strong>, developed with Unity, are a streamlined, arcade version of the game. The objective is simple. There are donuts. GET THEM. As many as possible. The game integrates the GREE platform for leaderboards and achievements.</p>
<p>DONUT GET! is available on:</p>
<ul>
<li>Apple App Store for iPhone, iPod Touch and iPad (<a href="http://www.donutget.com/download/iphone/" target="_blank">http://www.donutget.com/download/iphone/</a> )</li>
<li>Google Play Store for Android phones and tablets (<a href="http://www.donutget.com/download/android/" target="_blank">http://www.donutget.com/download/android/</a> )</li>
<li>Play it for FREE on the web at <a href="http://www.sokay.net/play/donut-get" target="_blank">http://www.sokay.net/play/donut-get</a></li>
</ul>
<p>&nbsp;</p>
<p>COME AND GET IT!</p>
<p>More information available at <a href="http://www.donutget.com/" target="_blank">http://www.donutget.com</a></p>
<p><strong>About Sokay.net</strong></p>
<p>Sokay.net is an independent game development team in Los Angeles, California. They say it never rains in Southern California. At Sokay, we make it rain. Sokay.net has developed the games Thugjacker, LUV Tank, Rush Hour Plus and Sammy Samurai.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2012/10/29/donut-get-now-available-for-iphone-ipad-and-android/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Donut Get! Devlog – October 3, 2012</title>
		<link>http://blog.sokay.net/2012/10/03/donut-get-devlog-october-3-2012/</link>
		<comments>http://blog.sokay.net/2012/10/03/donut-get-devlog-october-3-2012/#comments</comments>
		<pubDate>Wed, 03 Oct 2012 21:23:02 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[Donut Get!]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Sokay Development]]></category>
		<category><![CDATA[Sokay Games]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[donut]]></category>
		<category><![CDATA[donut get]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[google play]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[Los Angeles]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1764</guid>
		<description><![CDATA[[Partial repost from our Tigsource DevLog] ANNOUNCING &#8212; DONUT GET! for Android Has Been Released! Download it for FREE at: https://play.google.com/store/apps/details?id=net.sokay.DonutGet Last week I spent some time prototyping our next game in Unity. Of the block matching puzzle game variety. This week I jumped back to focusing on Donut Get! iPad version and finishing up [...]]]></description>
				<content:encoded><![CDATA[<p><center><a href="http://forums.tigsource.com/index.php?topic=19958.msg798554#msg798554" target="_blank">[Partial repost from our Tigsource DevLog]</a></center></p>
<p><strong>ANNOUNCING &#8212; DONUT GET! for Android Has Been Released!</strong></p>
<p><center><a href="https://play.google.com/store/apps/details?id=net.sokay.DonutGet" target="_blank"><img src="http://www.donutget.com/images/promo/donutget_gree_icon.png" ></p>
<p><img src="http://www.donutget.com/images/promo/android_app_on_play_large.png" ></a></p>
<p>Download it for FREE at:<br />
<a href="https://play.google.com/store/apps/details?id=net.sokay.DonutGet" target="_blank">https://play.google.com/store/apps/details?id=net.sokay.DonutGet</a></center></p>
<hr/>
<p>Last week I spent some time prototyping our next game in Unity. Of the block matching puzzle game variety.</p>
<p>This week I jumped back to focusing on Donut Get! iPad version and finishing up where I left off with the in app purchasing. I was running into a problem of it just crashing when a purchase started so I had to do a bit of optimizing to prevent that. So far so good, as now I can at least get it to work!</p>
<p><center><img src="http://www.donutget.com/images/promo/donutget_ipad_buy_01.jpg" ><br />
<i>In app purchase screen to remove ads.</i></center></p>
<p><center><img src="http://www.donutget.com/images/promo/donutget_ipad_buy_02.jpg" ><br />
<i>Thank you screen!</i></center></p>
<p>The textures for the sprite animation is eating up a ton of memory. I&#8217;ve tried to keep the cop animation sharp and crisp but I&#8217;ve had to bring down the res a bit to accommodate all the lower-end devices it keeps crashing. <img src='http://blog.sokay.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  So for now, I&#8217;m trying to stop crashing Android phone! haha</p>
<p>Later I hope to do some research to switch between spritesheets based on the memory available on the device. Not quite sure if that&#8217;s possible/reasonable yet.</p>
<p><a href="https://play.google.com/store/apps/details?id=net.sokay.DonutGet" target="_blank">Donut Get! Android is available on Google Play</a> so check it out if you can. Let me know how it works for you!</p>
<p>iPhone version available soon!</p>
<p>The OG Flash version still at <a href="http://www.sokay.net/play/donut-get" target="_blank">http://www.sokay.net/play/donut-get</a></p>
<p>Thanks for reading.</p>
<p>Peace!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2012/10/03/donut-get-devlog-october-3-2012/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Stars and Clouds in Away 3D 4.0</title>
		<link>http://blog.sokay.net/2012/09/06/stars-and-clouds-in-away-3d-4-0/</link>
		<comments>http://blog.sokay.net/2012/09/06/stars-and-clouds-in-away-3d-4-0/#comments</comments>
		<pubDate>Thu, 06 Sep 2012 18:46:00 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[3d perlin noise]]></category>
		<category><![CDATA[away 3d]]></category>
		<category><![CDATA[away 3d 4.0]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1746</guid>
		<description><![CDATA[Shortly after I posted my tutorial on creating a Starfield with Away 3D Lite I tried to see how much I could improve performance with Away 3D 4.0, which was Flash 11 and in Beta stage at the time. I got caught up with finishing Donut Get! and working on Unity stuff and forgot about [...]]]></description>
				<content:encoded><![CDATA[<p>Shortly after I posted my tutorial on <a href="http://blog.sokay.net/2012/03/27/simple-starfield-with-away-3d-lite/" target="_blank">creating a Starfield with Away 3D Lite</a> I tried to see how much I could improve performance with Away 3D 4.0, which was Flash 11 and in Beta stage at the time. I got caught up with finishing <a href="http://www.sokay.net/play/donut-get" target="_blank">Donut Get!</a> and working on <a href="http://blog.sokay.net/2012/08/14/loading-xml-in-unity-building-a-stage-from-xml/" target="_blank">Unity stuff</a> and forgot about making a post about the demo. Here&#8217;s a post about that Away 3D 4.0 demo I made.</p>
<p>This was inspired by playing <a href="https://www.youtube.com/watch?v=Hu64yNy5j1s" target="_blank">Kid Icarus on 3DS</a>. During the flying segments, you&#8217;re always flying through clouds which is a great effect. I think they do something similar to this, where the clouds are 3d slices of a cloud which you pass through.</p>
<p>I created the clouds with noise. To get &#8220;3D slices&#8221; I used a <a href="http://www.sjeiti.com/perlin-noise-in-as3/" target="_blank">3d Perlin noise generator by Ron Valstar</a>. The regular Flash noise class lets you generate noise on X and Y axis, this allows you to move in the Z axis to create slices.</p>
<p style="text-align: center;"><a href="http://blog.sokay.net/stuff/starfield2/" target="_blank"><img class="aligncenter size-full wp-image-1747" title="blogtut_3d_clouds" alt="" src="http://blog.sokay.net/wp-content/uploads/2012/09/blogtut_3d_clouds.jpg" width="450" height="339" /></a><br />
<em>View the tutorial demo here: <a href="http://blog.sokay.net/stuff/starfield2/" target="_blank">http://blog.sokay.net/stuff/starfield2/</a></em></p>
<p>I used Sprite3Ds for the cloud slices, hoping that that would allow me to use a greater amount of cloud slices. In this demo I&#8217;m using 12 separate Sprite3D instances. It takes a while to generate the noise at the beginning, I don&#8217;t think this noise generator anywhere near as fast as Flash&#8217;s internal one unfortunately. I spent a long ass time adjusting the Generator and settled on this result which I felt was looking pretty good, rather than just settling for something that was fast to generate.</p>
<p>Sprite3D displays like a billboard/plane in 3D space that is always pointed towards the camera. The problem with Sprite3D is that it&#8217;s displayed as a point in space, and if the point isn&#8217;t within the camera viewport, it doesn&#8217;t display at all. You can see this issue as you rotate the camera to the side. I tried a list minute fix to change it to planes but I couldn&#8217;t get the planes to display. It may have something to do with the scale of the scene, the slices are like 15,000 width. Not spending any time trying to figure it out so good luck with it if you wanna try!<br />
<span id="more-1746"></span><br />
Here is the source of the StarField class, which sets up the Away3D scene:</p>
<div class="codecolorer-container actionscript3 railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br />161<br />162<br />163<br />164<br />165<br />166<br />167<br />168<br />169<br />170<br />171<br />172<br />173<br />174<br />175<br />176<br />177<br />178<br />179<br />180<br />181<br />182<br />183<br />184<br />185<br />186<br />187<br />188<br />189<br />190<br />191<br />192<br />193<br />194<br />195<br />196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br />211<br />212<br />213<br />214<br />215<br />216<br />217<br />218<br />219<br />220<br />221<br />222<br />223<br />224<br />225<br />226<br />227<br />228<br />229<br />230<br />231<br />232<br />233<br />234<br />235<br />236<br />237<br />238<br />239<br />240<br />241<br />242<br />243<br />244<br />245<br />246<br />247<br />248<br />249<br />250<br />251<br />252<br />253<br />254<br />255<br />256<br />257<br />258<br />259<br />260<br />261<br />262<br />263<br />264<br />265<br />266<br />267<br />268<br />269<br />270<br />271<br />272<br />273<br />274<br />275<br />276<br />277<br />278<br />279<br />280<br />281<br />282<br />283<br />284<br />285<br />286<br />287<br />288<br />289<br />290<br />291<br />292<br />293<br />294<br />295<br />296<br />297<br />298<br />299<br />300<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> StarField <span style="color: #0033ff; font-weight: bold;">extends</span> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><br />
<span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> m_camera<span style="color: #000066; font-weight: bold;">:</span>Camera3D<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> m_view<span style="color: #000066; font-weight: bold;">:</span>View3D<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> m_scene<span style="color: #000066; font-weight: bold;">:</span>Scene3D<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> starContainer<span style="color: #000066; font-weight: bold;">:</span>ObjectContainer3D<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> starCount<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> stars<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> cloudSliceCount<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> clouds<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.;</span><br />
<span style="color: #009900; font-style: italic;">//private var clouds:Vector.;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> cloudDistance<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">10000</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> cloudTestBitmap<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> cloudTestBitmapData<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> genClouds<span style="color: #000066; font-weight: bold;">:</span>GenerateClouds<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//you can import an image like this</span><br />
<span style="color: #009900; font-style: italic;">//[Embed(source = &quot;../assets/star.png&quot; , mimeType=&quot;image/png&quot;)]</span><br />
<span style="color: #009900; font-style: italic;">//private var starArt:Class;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> starArt<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// in this tutorial we'll create a bitmapData from scratch</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> rotateSpeed<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> rotateDirection<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;none&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> StarField<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #004993;">mouseChildren</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">mouseEnabled</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">/// clouds</span><br />
<br />
genClouds = <span style="color: #0033ff; font-weight: bold;">new</span> GenerateClouds<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
cloudTestBitmapData = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span>0xFFFF0000<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
cloudTestBitmap = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000000;">&#40;</span>cloudTestBitmapData<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>cloudTestBitmap<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">////////</span><br />
<br />
initView<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
initObjects<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">/////////</span><br />
<br />
<span style="color: #009900; font-style: italic;">//genClouds.generateCloudSlice(cloudTestBitmap);</span><br />
<br />
<span style="color: #009900; font-style: italic;">/// ENTERFRAME</span><br />
<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> act<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> initView<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// create view</span><br />
m_view = <span style="color: #0033ff; font-weight: bold;">new</span> View3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>m_view<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">//m_view.antiAlias = 4;</span><br />
<br />
m_view<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">backgroundColor</span> = 0x0033CC<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// debug</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> stats<span style="color: #000066; font-weight: bold;">:</span>AwayStats = <span style="color: #0033ff; font-weight: bold;">new</span> AwayStats<span style="color: #000000;">&#40;</span>m_view<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: #000066; font-weight: bold;">;</span><br />
stats<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">450</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>stats<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// scene</span><br />
<br />
m_scene = m_view<span style="color: #000066; font-weight: bold;">.</span>scene<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// camera</span><br />
<br />
m_camera = m_view<span style="color: #000066; font-weight: bold;">.</span>camera<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//set camera location</span><br />
m_view<span style="color: #000066; font-weight: bold;">.</span>camera<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
m_view<span style="color: #000066; font-weight: bold;">.</span>camera<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
m_view<span style="color: #000066; font-weight: bold;">.</span>camera<span style="color: #000066; font-weight: bold;">.</span>z = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">//m_view.camera.zoom = 10;</span><br />
<span style="color: #009900; font-style: italic;">//m_view.camera.focus = 30;</span><br />
<br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>lens<span style="color: #000066; font-weight: bold;">.</span>far = <span style="color: #000000; font-weight:bold;">100000</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> initLights<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> initObjects<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
<br />
starContainer = <span style="color: #0033ff; font-weight: bold;">new</span> ObjectContainer3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
m_scene<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>starContainer<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//create bitmapData for our material, 4x4 and white! (0xffffff)</span><br />
starArt = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span>0xFFFFFF<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// create an Away3D Material with that bitmapData, this is the image used for our particles!</span><br />
<br />
<span style="color: #009900; font-style: italic;">//var starMaterial:BitmapMaterial = new BitmapMaterial(new starArt().bitmapData); // use this if you decide to import an asset</span><br />
<span style="color: #009900; font-style: italic;">//var starMaterial:BitmapMaterial = new BitmapMaterial(starArt); // BitmapMaterial() is deprecated</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> starBitmapTexture<span style="color: #000066; font-weight: bold;">:</span>BitmapTexture = <span style="color: #0033ff; font-weight: bold;">new</span> BitmapTexture<span style="color: #000000;">&#40;</span>starArt<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> starMaterial<span style="color: #000066; font-weight: bold;">:</span>TextureMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> TextureMaterial<span style="color: #000000;">&#40;</span>starBitmapTexture<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> starMaterial2<span style="color: #000066; font-weight: bold;">:</span>ColorMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> ColorMaterial<span style="color: #000000;">&#40;</span>0xFFFFFF<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> cloudBitmapTexture<span style="color: #000066; font-weight: bold;">:</span>BitmapTexture = <span style="color: #0033ff; font-weight: bold;">new</span> BitmapTexture<span style="color: #000000;">&#40;</span>genClouds<span style="color: #000066; font-weight: bold;">.</span>getCloudSlice<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> cloudMaterial<span style="color: #000066; font-weight: bold;">:</span>TextureMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> TextureMaterial<span style="color: #000000;">&#40;</span>cloudBitmapTexture<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
cloudMaterial<span style="color: #000066; font-weight: bold;">.</span>alphaBlending = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// create a Vector array to the size of &quot;starCount&quot;</span><br />
stars = <span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #000000;">&#40;</span>starCount <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: #000066; font-weight: bold;">;</span><br />
clouds = <span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #000000;">&#40;</span>cloudSliceCount <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: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// merge</span><br />
<span style="color: #009900; font-style: italic;">//var merge:Merge = new Merge();</span><br />
<br />
<span style="color: #009900; font-style: italic;">// start filling the Vector with Sprite3D objects!</span><br />
<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><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <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;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> starCount<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><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> starMaterial3<span style="color: #000066; font-weight: bold;">:</span>ColorMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> ColorMaterial<span style="color: #000000;">&#40;</span>0xFFFFFF<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> star<span style="color: #000066; font-weight: bold;">:</span>Sprite3D = <span style="color: #0033ff; font-weight: bold;">new</span> Sprite3D<span style="color: #000000;">&#40;</span>starMaterial3<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//star.alignmentType = AlignmentType.VIEWPOINT; // I forgot what this does... haha! look it up!</span><br />
<br />
star<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;">400</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><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;">800</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
star<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;">500</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><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;">800</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
star<span style="color: #000066; font-weight: bold;">.</span>z = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1000</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><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;">&#40;</span><span style="color: #000000; font-weight:bold;">1000</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">800</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">///m_scene.addChild(star);</span><br />
starContainer<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>star<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//merge.apply(starContainer, star);</span><br />
<br />
stars<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = star<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// clouds</span><br />
<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;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> cloudSliceCount<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><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> cloudBitmapTextureTemp<span style="color: #000066; font-weight: bold;">:</span>BitmapTexture = <span style="color: #0033ff; font-weight: bold;">new</span> BitmapTexture<span style="color: #000000;">&#40;</span>genClouds<span style="color: #000066; font-weight: bold;">.</span>getCloudSlice<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> cloudMaterialTemp<span style="color: #000066; font-weight: bold;">:</span>TextureMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> TextureMaterial<span style="color: #000000;">&#40;</span>cloudBitmapTextureTemp<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
cloudMaterialTemp<span style="color: #000066; font-weight: bold;">.</span>alphaBlending = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> cloud<span style="color: #000066; font-weight: bold;">:</span>Sprite3D = <span style="color: #0033ff; font-weight: bold;">new</span> Sprite3D<span style="color: #000000;">&#40;</span>cloudMaterialTemp<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">15000</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">13000</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// trying Sprite3D, disappear when center isn't in frame :(</span><br />
<span style="color: #009900; font-style: italic;">//var cloudShape:PlaneGeometry = new PlaneGeometry(15000,13000,1,1); // trying Meshes but the scale may be to huge, they werent displaying</span><br />
<span style="color: #009900; font-style: italic;">//var cloud:Mesh = new Mesh(cloudShape,cloudMaterialTemp);</span><br />
<span style="color: #009900; font-style: italic;">//cloudShape = null;</span><br />
<br />
cloud<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
cloud<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
cloud<span style="color: #000066; font-weight: bold;">.</span>z = <span style="color: #000066; font-weight: bold;">-</span>cloudDistance <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>cloudDistance <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: #000000;">&#40;</span>cloudSliceCount <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> i <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
m_scene<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>cloud<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
clouds<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = cloud<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// sets the rotation to look in a certain direction</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> lookForward<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationY = <span style="color: #000000; font-weight:bold;">180</span><span style="color: #000066; font-weight: bold;">;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationX = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> lookBackward<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationY = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationX = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> lookLeft<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationY = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">90</span><span style="color: #000066; font-weight: bold;">;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationX = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> lookRight<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationY = <span style="color: #000000; font-weight:bold;">90</span><span style="color: #000066; font-weight: bold;">;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationX = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// set a rotation direction with the keys</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> rotateLeft<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
rotateDirection = <span style="color: #990000;">&quot;left&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> rotateRight<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
rotateDirection = <span style="color: #990000;">&quot;right&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> rotateUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
rotateDirection = <span style="color: #990000;">&quot;up&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> rotateDown<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
rotateDirection = <span style="color: #990000;">&quot;down&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> rotateNone<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
rotateDirection = <span style="color: #990000;">&quot;none&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> act<span style="color: #000000;">&#40;</span> e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
<br />
onPreRender<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
m_view<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// this onPreRender function fires every frame, thanks to our nift Away3d template file!</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> onPreRender<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><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> starCount<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = stars<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span><br />
<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><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <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;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> starCount<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><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> star<span style="color: #000066; font-weight: bold;">:</span>Sprite3D = stars<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
star<span style="color: #000066; font-weight: bold;">.</span>z <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: #009900; font-style: italic;">// stars move forward on Z-axis every frame</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>star<span style="color: #000066; font-weight: bold;">.</span>z <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">800</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
star<span style="color: #000066; font-weight: bold;">.</span>z = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// when stars move past limit of 800, set them back to -1000 so they loop forever!</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// fade</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> starZ<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = star<span style="color: #000066; font-weight: bold;">.</span>z<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>starZ <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> starZ <span style="color: #000066; font-weight: bold;">*</span>= <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> facePerc2<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = starZ <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">800</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">//trace(&quot;fadePerc: &quot; + facePerc);</span><br />
ColorMaterial<span style="color: #000000;">&#40;</span>star<span style="color: #000066; font-weight: bold;">.</span>material<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000;">&#40;</span>facePerc2 <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> cloudCount<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = clouds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span><br />
<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><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> j <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> cloudCount<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><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> cloud<span style="color: #000066; font-weight: bold;">:</span>Sprite3D = clouds<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
cloud<span style="color: #000066; font-weight: bold;">.</span>z <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// stars move forward on Z-axis every frame</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>cloud<span style="color: #000066; font-weight: bold;">.</span>z <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span>= cloudDistance<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> cloudBitmapTextureTemp<span style="color: #000066; font-weight: bold;">:</span>BitmapTexture = <span style="color: #0033ff; font-weight: bold;">new</span> BitmapTexture<span style="color: #000000;">&#40;</span>genClouds<span style="color: #000066; font-weight: bold;">.</span>getCloudSlice<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> cloudMaterialTemp<span style="color: #000066; font-weight: bold;">:</span>TextureMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> TextureMaterial<span style="color: #000000;">&#40;</span>cloudBitmapTextureTemp<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
cloudMaterialTemp<span style="color: #000066; font-weight: bold;">.</span>alphaBlending = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
cloud<span style="color: #000066; font-weight: bold;">.</span>material = cloudMaterialTemp<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
cloud<span style="color: #000066; font-weight: bold;">.</span>z = <span style="color: #000066; font-weight: bold;">-</span>cloudDistance<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// when stars move past limit of 800, set them back to -1000 so they loop forever!</span><br />
<span style="color: #009900; font-style: italic;">//TextureMaterial(cloud.material).alpha = 1;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// fade</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> cloudZ<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = cloud<span style="color: #000066; font-weight: bold;">.</span>z<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>cloudZ <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> cloudZ <span style="color: #000066; font-weight: bold;">*</span>= <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> facePerc<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = cloudZ <span style="color: #000066; font-weight: bold;">/</span> cloudDistance<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">//trace(&quot;fadePerc: &quot; + facePerc);</span><br />
TextureMaterial<span style="color: #000000;">&#40;</span>cloud<span style="color: #000066; font-weight: bold;">.</span>material<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000066; font-weight: bold;">-</span> facePerc<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/*<br />
starContainer.z += 20;<br />
if (starContainer.z &amp;gt; 800) {<br />
starContainer.z = -1000;<br />
}<br />
*/</span><br />
<br />
<span style="color: #009900; font-style: italic;">// handle rotations!</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>rotateDirection == <span style="color: #990000;">&quot;left&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationY <span style="color: #000066; font-weight: bold;">-</span>= rotateSpeed<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>rotateDirection == <span style="color: #990000;">&quot;right&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationY <span style="color: #000066; font-weight: bold;">+</span>= rotateSpeed<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>rotateDirection == <span style="color: #990000;">&quot;up&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationX <span style="color: #000066; font-weight: bold;">-</span>= rotateSpeed<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>rotateDirection == <span style="color: #990000;">&quot;down&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
m_camera<span style="color: #000066; font-weight: bold;">.</span>rotationX <span style="color: #000066; font-weight: bold;">+</span>= rotateSpeed<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// new cloud slice</span><br />
<span style="color: #009900; font-style: italic;">//genClouds.generateCloudSlice(cloudTestBitmap);</span><br />
cloudTestBitmap<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span> = genClouds<span style="color: #000066; font-weight: bold;">.</span>getCloudSlice<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>And here&#8217;s the class I used to generate the slices &#8216;o&#8217; clouds. I generate 50 128&#215;128 bitmapDatas of Noise, spread out over the Z axis. Then swap these out between the 12 cloud slice Sprite3Ds. When the cloud slice reaches the end of the area, it moves back to the other end and gets a new cloud noise texture.</p>
<div class="codecolorer-container actionscript3 railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> GenerateClouds<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> baseX<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> baseY<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> numOctaves<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> randomSeed<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">13</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> stitch<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> fractalNoise<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> channelOptions<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> grayScale<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> offsets<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> cmf<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=colormatrixfilter%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:colormatrixfilter.html"><span style="color: #004993;">ColorMatrixFilter</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> cloudSlices<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> sliceWidth<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">128</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> sliceHeight<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">128</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> sliceZ<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> currentSlice<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> totalSlices<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> GenerateClouds<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #004993;">bitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span>sliceWidth<span style="color: #000066; font-weight: bold;">,</span>sliceHeight<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: #000066; font-weight: bold;">;</span><br />
<br />
cmf = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=colormatrixfilter%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:colormatrixfilter.html"><span style="color: #004993;">ColorMatrixFilter</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">255</span><span style="color: #000066; font-weight: bold;">,</span><br />
<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">255</span><span style="color: #000066; font-weight: bold;">,</span><br />
<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">255</span><span style="color: #000066; font-weight: bold;">,</span><br />
<span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
cmf = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=colormatrixfilter%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:colormatrixfilter.html"><span style="color: #004993;">ColorMatrixFilter</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">255</span><span style="color: #000066; font-weight: bold;">,</span><br />
<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">255</span><span style="color: #000066; font-weight: bold;">,</span><br />
<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">255</span><span style="color: #000066; font-weight: bold;">,</span><br />
<span style="color: #000000; font-weight:bold;">0.4</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
generateSlices<span style="color: #000000;">&#40;</span>totalSlices<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #3f5fbf;">/*<br />
var myBitmapDataObject:BitmapData = new BitmapData(640, 480);<br />
//var seed:Number = Math.floor(Math.random()*100);<br />
//myBitmapDataObject.perlinNoise(320, 240, 8, seed, true, true, 7, false, null);<br />
var myBitmap:Bitmap = new Bitmap(myBitmapDataObject);<br />
addChildAt(myBitmap, 0);<br />
*/</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> generateSlices<span style="color: #000000;">&#40;</span> _count<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
<br />
cloudSlices = <span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #000000;">&#40;</span>_count<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: #000066; font-weight: bold;">;</span><br />
<br />
Perlin<span style="color: #000066; font-weight: bold;">.</span>octaves = <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">;</span><br />
Perlin<span style="color: #000066; font-weight: bold;">.</span>falloff = <span style="color: #000000; font-weight:bold;">0.01</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<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><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <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;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> _count<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><br />
<br />
generateCloudSlice<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">applyFilter</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> cmf<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
cloudSlices<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = <span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">clone</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> generateCloudSlice<span style="color: #000000;">&#40;</span> _count<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> bd<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a> = <span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> depthSpeed<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<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><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <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;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> bd<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</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><br />
<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><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>j <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> bd<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</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><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">size</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> fNoise<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = Perlin<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">noise</span><span style="color: #000000;">&#40;</span> i<span style="color: #000066; font-weight: bold;">/</span><span style="color: #004993;">size</span><span style="color: #000066; font-weight: bold;">,</span> j<span style="color: #000066; font-weight: bold;">/</span><span style="color: #004993;">size</span><span style="color: #000066; font-weight: bold;">,</span> _count <span style="color: #000066; font-weight: bold;">*</span> depthSpeed <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> iNoise<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">.</span>5<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><span style="color: #000000;">&#40;</span>fNoise<span style="color: #000066; font-weight: bold;">-.</span>5<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">255</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> iColor<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = iNoise <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">16</span> <span style="color: #000066; font-weight: bold;">|</span> iNoise <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">8</span> <span style="color: #000066; font-weight: bold;">|</span> iNoise<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> iAlpha<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000;">&#40;</span>iColor<span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;&amp;</span>gt<span style="color: #000066; font-weight: bold;">;&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span><span style="color: #000000; font-weight:bold;">24</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> iCompsite<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = iAlpha <span style="color: #000066; font-weight: bold;">+</span> iColor<span style="color: #000066; font-weight: bold;">;</span><br />
bd<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setPixel</span><span style="color: #000000;">&#40;</span>i<span style="color: #000066; font-weight: bold;">,</span>j<span style="color: #000066; font-weight: bold;">,</span> iColor <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> getCloudSlice<span style="color: #000000;">&#40;</span> _number<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <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> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a> <span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_number == <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: #000000;">&#123;</span><br />
_number = currentSlice<span style="color: #000066; font-weight: bold;">++;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>currentSlice<span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span>= totalSlices<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
currentSlice = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//_bitmap.bitmapData = cloudSlices[_number].clone();</span><br />
<span style="color: #3f5fbf;">/*<br />
var clone:BitmapData = cloudSlices[_number].clone();<br />
var alpha:BitmapData = new BitmapData(clone.width,clone.height, true, 0xFFFFFFFF);<br />
alpha.fillRect(new Rectangle(0,0,25, 50), 0x00000000);<br />
<br />
var bd:BitmapData = new BitmapData(clone.width,clone.height, true)<br />
bd.copyPixels(clone, new Rectangle(0,0,clone.width,clone.height), new Point(0,0), clone, new Point(0,0), false);<br />
*/</span><br />
<span style="color: #009900; font-style: italic;">//return bd;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> cloudSlices<span style="color: #000000;">&#91;</span>_number<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">clone</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> getSlice<span style="color: #000000;">&#40;</span>_sliceNum<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a> <span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> bd<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span><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><br />
<br />
bd<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">copyPixels</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">100</span><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> <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</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: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">return</span> bd<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Download the source here:</p>
<ul>
<li><a href="http://blog.sokay.net/stuff/starfield2/SokayStarField2_src.Sep.06.2012.zip" target="_blank">SokayStarField2_src.Sep.06.2012.zip</a></li>
</ul>
<p>In the end, the speed wasn&#8217;t as fast as I was expecting. I figure it might have something to do with the number of particles and objects I was displaying, and not just the complexity. Don&#8217;t get me wrong, it&#8217;s a lot faster than what I was using while working on the <a title="Soul Calibur -  Soul Archive in Away 3D" href="http://soulcalibur.com/en_US#/characters" target="_blank">Soul Calibur site</a>, but not that Unreal Demo speed. Still don&#8217;t know what I&#8217;m doing wrong&#8230; Oh well! haha</p>
<p>(this demo used Away 3D 4.0 beta55)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2012/09/06/stars-and-clouds-in-away-3d-4-0/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Loading XML in Unity &#8211; Building a Stage From XML</title>
		<link>http://blog.sokay.net/2012/08/14/loading-xml-in-unity-building-a-stage-from-xml/</link>
		<comments>http://blog.sokay.net/2012/08/14/loading-xml-in-unity-building-a-stage-from-xml/#comments</comments>
		<pubDate>Wed, 15 Aug 2012 07:04:28 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[level build]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[tablet]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[unity 3d]]></category>
		<category><![CDATA[unity3d]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1701</guid>
		<description><![CDATA[Ok, I had a hell of a time figuring out how to load in XML for a Unity project I&#8217;m working on and use it to build a level. Fortunately the Unity Community is vibrant and helpful, even though you may have to do digging to find what you&#8217;re looking for. It can be difficult [...]]]></description>
				<content:encoded><![CDATA[<p>Ok, I had a hell of a time figuring out how to load in XML for a Unity project I&#8217;m working on and use it to build a level. Fortunately the <a href="http://udn.unity3d.com/" target="_blank">Unity Community</a> is vibrant and helpful, even though you may have to do digging to find what you&#8217;re looking for. It can be difficult getting started, especially when working in C# as many of the examples are coded in Javascript.</p>
<p>Here&#8217;s an example of some game xml:</p>
<div class="codecolorer-container xml railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stageData<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stage<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1, 2, 3, A, B, C<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4, 5, 6, 7, 8, 9<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2, 1, 3, 5, 6, 2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stage<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0, 0, 0, 0, 0, 0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1, 1, 1, 1, 1, 1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>A, A, A, A, A, A<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3, 3, 3, 3, 3, 3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>C, C, C, C, C, C<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stage<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stageData<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>Keep in mind that there&#8217;s a million ways to go about doing this. I tried to justify why I did it this way, and the best I can say is &#8220;I just felt like it.&#8221; Haha!</p>
<p>I ended up using a C# port of this <a href="http://forum.unity3d.com/threads/38273-Lightweight-UnityScript-XML-parser" target="_blank">Lightweight XML parser</a>. The benefit of it supposedly is that it&#8217;s only 8k compared to a megabyte or so that would be added if you used the native C# class, System.XML. I used the C# port by chirhotec <a href="http://forum.unity3d.com/threads/38273-Lightweight-UnityScript-XML-parser?p=398520&amp;viewfull=1#post398520" target="_blank">in this post</a>. I had to make a small change, commenting out the &#8220;string nodeContents&#8221; line because the variable wasn&#8217;t used.<br />
<span id="more-1701"></span></p>
<h2>Where do we start???</h2>
<ul>
<li>Load some XML!</li>
</ul>
<div>So this is the first thing that got me stuck! My main problems getting started with Unity was figuring out how to go about accessing files or instantiating objects. So the first time I got this working, I screwed up&#8230;</div>
<div></div>
<div>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-style: italic;">// DON'T USE Resources.LoadAssetAtPath() !!!</span><br />
<br />
LevelXMLFile <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>TextAsset<span style="color: #008000;">&#41;</span> Resources<span style="color: #008000;">.</span><span style="color: #0000FF;">LoadAssetAtPath</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Assets/PathToFile/StageData.xml&quot;</span>, <a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #008000;">&#40;</span>TextAsset<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></td></tr></tbody></table></div>
</div>
<div>Resources.LoadAssetAtPath() only works in the editor. I found this out the hard way when my stages weren&#8217;t working when testing on my iPad and Android Tablet. Fortunately the fix was easy&#8230;</div>
<div></div>
<div>First you have to move your XML file into a &#8220;Resources&#8221; folder within the root of your &#8220;Assets&#8221; folder. Using the resources class, you can grab a reference to any file in that folder. Like so!</div>
<div></div>
<div>
<div class="codecolorer-container xml railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">// DO IT THIS WAY INSTEAD!!!<br />
<br />
LevelXMLFile = (TextAsset) Resources.Load(&quot;StageData&quot;, typeof(TextAsset));</div></td></tr></tbody></table></div>
</div>
<div></div>
<p>Now that you have your reference to your XML, it&#8217;s time to parse it! To get at all that gooood data.</p>
<h2>So&#8230;. What next???</h2>
<div>
<ul>
<li>Parse some XML!</li>
</ul>
<p>So for my needs, I needed to find a way to loop through each map node, grab the string, and parse out the individual numbers to build a stage. I learned a technique like this working with building tile-based maps.</p>
<p>Here&#8217;s an example of how to get to this data using the <a href="http://forum.unity3d.com/threads/38273-Lightweight-UnityScript-XML-parser" target="_blank">Lightweight XML parser</a>&#8230;
</div>
<div>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-style: italic;">// parse the XML file</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> XMLParser parser <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> XMLParser<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> XMLNode LevelXML <span style="color: #008000;">=</span> parser<span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>LevelXMLFile<span style="color: #008000;">.</span><span style="color: #0000FF;">text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<br />
<span style="color: #008080; font-style: italic;">// grab the content of one row, shove it in a string array!</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> currentRowString <span style="color: #008000;">=</span> LevelXML<span style="color: #008000;">.</span><span style="color: #0000FF;">GetValue</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;data&gt;0&gt;stage&gt;0&gt;map&gt;0&gt;_text&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> currentRow <span style="color: #008000;">=</span> currentRowString<span style="color: #008000;">.</span><span style="color: #0000FF;">Split</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">','</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></td></tr></tbody></table></div>
</div>
<p>Now that&#8217;s great! But that&#8217;s not very useful. I may have hundreds of rows, so I need to find a way to loop through them.</p>
<div>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-style: italic;">// find out how many stages there are</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> stageCount <span style="color: #008000;">=</span> LevelXML<span style="color: #008000;">.</span><span style="color: #0000FF;">GetNodeList</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;data&gt;0&gt;stage&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span><br />
<br />
<br />
<span style="color: #008080; font-style: italic;">// find out how many map nodes there are in the XML for the first stage</span><br />
<span style="color: #008080; font-style: italic;">// (hint: I count three!)</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> currentStage <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #6666cc; font-weight: bold;">string</span> _stage <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>currentStage <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// subtracting one, because the XML node always starts at zero! Converting it to a string so I can pass it into my GetNodeList function...</span><br />
<br />
currentMapLength <span style="color: #008000;">=</span> LevelXML<span style="color: #008000;">.</span><span style="color: #0000FF;">GetNodeList</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;data&gt;0&gt;stage&gt;&quot;</span> <span style="color: #008000;">+</span> _stage <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;&gt;map&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// checks how many map nodes are within the first stage node</span></div></td></tr></tbody></table></div>
</div>
<p>For clarification, what this is basically doing is&#8230;</p>
<div>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-style: italic;">// stage 1's map length would be 3, 3 xml nodes.</span><br />
<br />
currentMapLength <span style="color: #008000;">=</span> LevelXML<span style="color: #008000;">.</span><span style="color: #0000FF;">GetNodeList</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;data&gt;0&gt;stage&gt;0&gt;map&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span></div></td></tr></tbody></table></div>
</div>
<p>while&#8230;</p>
<div>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-style: italic;">// stage 2's map length would be 5, 5 xml nodes.</span><br />
<br />
currentMapLength <span style="color: #008000;">=</span> LevelXML<span style="color: #008000;">.</span><span style="color: #0000FF;">GetNodeList</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;data&gt;0&gt;stage&gt;1&gt;map&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span></div></td></tr></tbody></table></div>
</div>
<p>Now we can loop through these elements&#8230;</p>
<div>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> currentMapLength<span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// get an array of the current row</span><br />
<br />
&nbsp; &nbsp; currentRow <span style="color: #008000;">=</span> LevelXML<span style="color: #008000;">.</span><span style="color: #0000FF;">GetValue</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;data&gt;0&gt;stage&gt;&quot;</span> <span style="color: #008000;">+</span> _stage <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;&gt;map&gt;&quot;</span> <span style="color: #008000;">+</span> i <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;&gt;_text&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Split</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">','</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<p>So for stage 1, this would loop for 3 iterations.</p>
<ol>
<li><em>1, 2, 3, A, B, C</em></li>
<li><em>4, 5, 6, 7, 8, 9</em></li>
<li><em>2, 1, 3, 5, 6, 2</em></li>
</ol>
<p>And by using split() on this text string, it separates each character and places it into an array. In this case, we&#8217;re using &#8220;,&#8221; as the split delimiter. From there we can loop through each individual element&#8230;</p>
<div>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">...</span><br />
&nbsp; &nbsp; <span style="color: #0000FF;">currentRow</span> <span style="color: #008000;">=</span> LevelXML<span style="color: #008000;">.</span><span style="color: #0000FF;">GetValue</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;data&gt;0&gt;stage&gt;&quot;</span> <span style="color: #008000;">+</span> _stage <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;&gt;map&gt;&quot;</span> <span style="color: #008000;">+</span> i <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;&gt;_text&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Split</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">','</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> j <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> j <span style="color: #008000;">&lt;</span> currentRow<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span> j<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// get an array of the current row</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> currentElement <span style="color: #008000;">=</span> currentRow<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// trace out element to Debug window!</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Debug<span style="color: #008000;">.</span><span style="color: #0000FF;">Log</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;element #&quot;</span> <span style="color: #008000;">+</span> j <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; = &quot;</span> <span style="color: #008000;">+</span> currentElement<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">...</span></div></td></tr></tbody></table></div>
</div>
<p>So this is a quick and dirty example of how I got it to work. If you need me to clarify something, comment and I&#8217;ll see what I can do!</p>
<p>I&#8217;ve been a Unity enthusiast for a years but it&#8217;s taken some focus to really get down and dirty with it and figure out how to replicate all of the things I&#8217;m familiar with in Flash. I&#8217;ve been tackling issues with texturing, 2D sprite animation, UI and so on. Looking forward to sharing my learnings!</p>
<p>Peace!</p>
<p>-Bryson</p>
<p>&#8212;&#8212;&#8211;<br />
By the way, for code styling, I&#8217;m using the <a title="CodeColorer" href="http://kpumuk.info/projects/wordpress-plugins/codecolorer/">CodeColorer</a> Wordpress plugin. Super nifty!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2012/08/14/loading-xml-in-unity-building-a-stage-from-xml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Donut Get! Devlog &#8211; June 12, 2012</title>
		<link>http://blog.sokay.net/2012/06/12/donut-get-devlog-june-12-2012/</link>
		<comments>http://blog.sokay.net/2012/06/12/donut-get-devlog-june-12-2012/#comments</comments>
		<pubDate>Tue, 12 Jun 2012 15:29:07 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[Donut Get!]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Sokay Development]]></category>
		<category><![CDATA[devlog]]></category>
		<category><![CDATA[donut get]]></category>
		<category><![CDATA[sokay play]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1689</guid>
		<description><![CDATA[[Repost from our Tigsource DevLog] We&#8217;ll be debuting the game this week during Sokay Play 8! Our gallery show during the Downtown LA Art Walk&#8230; This week during the Downtown Los Angeles Art Walk. Check some photos from previous events on our Flickr.If you&#8217;re in the Los Angeles area, check it out. More info at [...]]]></description>
				<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://forums.tigsource.com/index.php?topic=19958.msg745023#msg745023" target="_blank">[Repost from our Tigsource DevLog]</a></p>
<p>We&#8217;ll be debuting the game this week during <a href="http://blog.sokay.net/category/sokay-play-downtown-la/" target="_blank">Sokay Play 8</a>! Our gallery show during the Downtown LA Art Walk&#8230;</p>
<p><center><img class="alignnone  wp-image-1694" title="sokay_play_flyer_08" src="http://blog.sokay.net/wp-content/uploads/2012/06/sokay_play_flyer_081.jpg" alt="" width="336" height="435" /><br />
<em>This week during the Downtown Los Angeles Art Walk. Check some photos from <a href="http://www.flickr.com/photos/sokayman/sets/" target="_blank">previous events on our Flickr.</a></em></center><center></center>If you&#8217;re in the Los Angeles area, check it out. More info at <a href="http://blog.sokay.net/category/sokay-play-downtown-la/" target="_blank">our blog</a>. We&#8217;ve been doing it every month so there&#8217;s always next month!</p>
<p>So E3 was this week so I went out and hung out the homies. Playing some games, drinking, etc etc.</p>
<p><center><img class="alignnone size-full wp-image-1691" title="donutget_e3_2012" src="http://blog.sokay.net/wp-content/uploads/2012/06/donutget_e3_2012.jpg" alt="" width="400" height="300" /><br />
<em>A lot of stupid times, but I had a blast!</em></center><center></center><br />
<span id="more-1689"></span><br />
Tried to get the word out on Donut Get! a bit, one step at a time! I had a blast though, nothing super exciting as far as games go from the show. But I had a blast with Wii U&#8217;s Nintendoland: Luigi&#8217;s Ghost Mansion (long name!). Fun use of multiplayer gameplay, great party game. I enjoyed what I played of Lost Planet 3 but I&#8217;m super biased cause some homies worked on it, generally not a big fan of 3rd person shooters but they put a lot of attention into the atmospheric details that I dug. And Resident Evil 6 is like one of the most polished and beautiful games ever&#8230;</p>
<p>So I&#8217;m switching gears from one hard part of the game (development), to the other part (letting people know!) I&#8217;m hoping that I can get the word out!</p>
<p>So some more images from the game&#8230;</p>
<p><center><img class="alignnone size-full wp-image-1693" title="donutget_screen_03" src="http://blog.sokay.net/wp-content/uploads/2012/06/donutget_screen_03.jpg" alt="" width="380" height="500" /><br />
<em>So this is what the Donut segment is looking like</em></center><center></center>There&#8217;s a progression as the shop slowly burns down and the gameplay donut drop pattern ramps up.</p>
<p><center><img class="alignnone size-full wp-image-1695" title="donutget_luv_02" src="http://blog.sokay.net/wp-content/uploads/2012/06/donutget_luv_02.png" alt="" width="380" height="500" /><br />
<em>Here&#8217;s a segment from the game&#8217;s ending.</em></center><center></center>I hope I&#8217;m not showing too much! Hahaha!</p>
<p><center><strong>Donut Get! Beta</strong></center>So I&#8217;m starting to send out the links to the Donut Get! Beta. If you&#8217;re interested in playing it a bit early, go to <a href="http://www.donutget.com" target="_blank">www.donutget.com</a> and sign up for our newsletter. I&#8217;ll be sending the link out soon. If you can give some feedback, that would be greatly appreciated!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2012/06/12/donut-get-devlog-june-12-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sokay Play 8 @ Downtown LA Art Walk</title>
		<link>http://blog.sokay.net/2012/06/10/sokay-play-8-downtown-la-art-walk/</link>
		<comments>http://blog.sokay.net/2012/06/10/sokay-play-8-downtown-la-art-walk/#comments</comments>
		<pubDate>Mon, 11 Jun 2012 04:22:59 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[Donut Get!]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Sokay Games]]></category>
		<category><![CDATA[Sokay Play]]></category>
		<category><![CDATA[#dtla]]></category>
		<category><![CDATA[artwalk]]></category>
		<category><![CDATA[donut get]]></category>
		<category><![CDATA[downtown los angels]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[sokay play]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1684</guid>
		<description><![CDATA[Sokay Play 8 is Thursday this week during the Downtown Los Angeles Art Walk. Check some photos from a previous event on our Flickr. &#160; SOKAY PLAY 8 THURSDAY, June 14, 2012 FROM LIKE 8PM &#8211; MIDNIGHT During the Downtown Los Angeles Art Walk @ The Medallion 334 S. Main St Unit #334-5012 Los Angeles, [...]]]></description>
				<content:encoded><![CDATA[<p>Sokay Play 8 is Thursday this week during the Downtown Los Angeles Art Walk. Check some <a href="http://www.flickr.com/photos/sokayman/sets/72157629669640734/" target="_blank">photos from a previous event on our Flickr</a>.</p>
<p><img class="alignnone size-full wp-image-1685" title="sokay_play_flyer_08" src="http://blog.sokay.net/wp-content/uploads/2012/06/sokay_play_flyer_08.jpg" alt="" width="480" height="621" /></p>
<p>&nbsp;</p>
<p>SOKAY PLAY 8<br />
THURSDAY, June 14, 2012<br />
FROM LIKE 8PM &#8211; MIDNIGHT<br />
During the Downtown Los Angeles Art Walk</p>
<p>@ The Medallion<br />
334 S. Main St Unit #334-5012<br />
Los Angeles, 90013</p>
<p><strong>COME AND PLAY SOME GAMES!</strong></p>
<p>If you still don&#8217;t know what I&#8217;m talking about, check out a video from a previous show: <a title="Sokay Play 2" href="http://vimeo.com/33895049" target="_blank">http://vimeo.com/33895049</a></p>
<p>Peace!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2012/06/10/sokay-play-8-downtown-la-art-walk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Donut Get! Devlog &#8211; June 1, 2012</title>
		<link>http://blog.sokay.net/2012/06/01/donut-get-devlog-june-1-2012/</link>
		<comments>http://blog.sokay.net/2012/06/01/donut-get-devlog-june-1-2012/#comments</comments>
		<pubDate>Sat, 02 Jun 2012 05:58:28 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[Donut Get!]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Sokay Development]]></category>
		<category><![CDATA[devlog]]></category>
		<category><![CDATA[donut get]]></category>
		<category><![CDATA[items]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=1669</guid>
		<description><![CDATA[[repost from our TigSource DevLog] This week I started cleaning up some promo art that Ricky drew&#8230; Planning on making a Donut Get! t-shirt with this artwork. Sent out a Beta link to a buncha peeps yesterday, thinking through the feedback to see what I should try to address and what I&#8217;ll decide what is [...]]]></description>
				<content:encoded><![CDATA[<p style="text-align: center;">[<a href="http://forums.tigsource.com/index.php?topic=19958.msg741232#msg741232" target="_blank">repost from our TigSource DevLog</a>]</p>
<p>This week I started cleaning up some promo art that Ricky drew&#8230;</p>
<p><center><img src="http://www.donutget.com/images/promo/donutget_art_dnutted_sample.png" alt="" /><br />
Planning on making a Donut Get! t-shirt with this artwork.</center></p>
<p>Sent out a Beta link to a buncha peeps yesterday, thinking through the feedback to see what I should try to address and what I&#8217;ll decide what is &#8220;intended to be like that!&#8221; haha! It&#8217;s a tricky thing for me because there are some things people want/expect to be explained clear as day, while I intend for the game to be a bit of an exploration. You&#8217;ll figure out more about it the more times you play. But the major issues I&#8217;ll need to address first will be things that make it easier to replay &#8212; shortening slower parts, making it easier to skip parts, etc.</p>
<p>I&#8217;ve been reworking the Donut drop patterns which have been super rough. Trying to create a flow to it.</p>
<p><center><img src="http://www.donutget.com/images/promo/donutget_dropitems.png" alt="" /><br />
These are the items that fall from the sky in the Donut segment</center>There are 3 types of items that fall&#8230;</p>
<ul>
<li><strong>Donuts:</strong> variety of 5 types, these are like points</li>
<li><strong>Debris:</strong> these mess up your day, fall on your head and make you drop to the ground</li>
<li><strong>Coffee:</strong> speeds you up, makes your jumps floaty, lasts briefly</li>
</ul>
<p>With the unspoken objective of collecting as many donuts as possible, the player runs back and forth collecting donuts. Bouncing on the heads of the NPCs allows you to jump high into the sky and lets you collect many more donuts than you can get on the ground. You must do this while avoiding hazardous NPCs that knock you down or fight you. Also debris is falling as well so you need to avoid it. The coffee powerup is meant to be a temporary speed boost, I&#8217;m trying to design the pattern so that you can get a flow of coffee boosts if you navigate through the obstacles well.</p>
<p>Working on the donut drop pattern is a tedious mess because I&#8217;m doing it with a ghetto array and it takes a while to build the game and test changes. I would do this a completely different way if I was starting the project today but that&#8217;s another story&#8230; haha!</p>
<p>David&#8217;s waiting on me to do some more animation, I&#8217;m gonna setup some additional characters that will be added to the game sooner or later. And I need to take another pass at the fighting game&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2012/06/01/donut-get-devlog-june-1-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
