<?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>Cute Machine &#187; tutorial</title>
	<atom:link href="http://www.cutemachine.com/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cutemachine.com</link>
	<description>Learn • Create • Profit</description>
	<lastBuildDate>Tue, 22 Nov 2011 20:05:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>A Complete Game Made with Corona SDK &#8211; Tutorial Part 4</title>
		<link>http://www.cutemachine.com/corona-sdk-tutorial/a-complete-game-made-with-corona-sdk-tutorial-part-4/</link>
		<comments>http://www.cutemachine.com/corona-sdk-tutorial/a-complete-game-made-with-corona-sdk-tutorial-part-4/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 21:30:44 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[corona sdk]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.cutemachine.com/?p=863</guid>
		<description><![CDATA[Welcome back to the last part of the Corona SDK tutorial series. You might want to consider reading part one, part two, and part three first. In this part of the programming tutorial we will add the game logic, a menu, and the sound. The Code and Assets Before we go through the code, download [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><span class="drop_cap">W</span>elcome back to the last part of the Corona SDK tutorial series. You might want to consider reading <a href="http://www.cutemachine.com/product-creation/how-to-set-up-corona-to-build-your-first-ios-or-android-app/" title="Corona SDK Tutorial Part 1" target="_blank">part one</a>, <a href="http://www.cutemachine.com/corona-sdk-tutorial/basic-animations-and-player-control-with-corona-sdk-tutorial-part-2/" title="Corona SDK Tutorial Part 2" target="_blank">part two</a>, and <a href="http://www.cutemachine.com/corona-sdk-tutorial/use-box2d-for-collision-detection-with-corona-sdk-tutorial-part-3/" title="Corona SDK Tutorial Part 3" target="_blank">part three</a> first.</p>
<p>In this part of the programming tutorial we will add the game logic, a menu, and the sound.</p>
<h2 id="thecodeandassets">The Code and Assets</h2>
<p>Before we go through the code, download the complete <a href="http://www.cutemachine.com/wp-content/uploads/2011/08/Corona-SDK-Tutorial-Fat-Freddy-Project.zip" title="Corona SDK Tutorial Archive">Fat Freddy Corona SDK Tutorial Project</a>. This bundle includes the following assets:</p>
<ul>
<li><strong>Sound files</strong> pickup.wav, powerup.wav, failed.wav</li>
<li><strong>Source files</strong> build.settings, config.lua and main.lua</li>
<li><strong>Adobe Fireworks file</strong> FatFreddyLogoFireworks.png<a href="#fn:1" id="fnref:1" title="see footnote" class="footnote">[1]</a></li>
<li><strong>Icon files</strong> in various sizes. 512&#215;512, 57&#215;57, and 114&#215;114.</li>
</ul>
<p>Unpack the zip file somewhere on your hard disk. To start the game, just open the <code>main.lua</code> file in your Corona SDK Simulator.</p>
<p>A word of caution. In a real project you would do a lot of things differently from what I have done in this tutorial. For example, for simplicity we only have one code file. In a bigger project this will bring trouble. It is much better to have different source files for various parts of the project. Have a look at the <a href="http://rauberlabs.blogspot.com/2011/07/director-class-13.html" title="Director Class by Ricardo Rauber" target="_blank">Director Class for the Corona SDK</a> by <em>Ricardo Rauber</em>, to get a good start on structuring your next Corona SDK project.</p>
<p>You can do whatever you like with the project and the included files. Tweak it and learn. Let me know your achievements.</p>
<p>In the code you will find strange comments surrounding the function bodies: <code>---{{{</code> and <code>---}}}</code>. These comments are there to support code folding for the Vim editor. If you use a different editor you can ignore these tags.</p>
<h2 id="thegamelogic">The Game Logic</h2>
<p>The objective of the game is to collect the black squares and avoid touching the blue squares. The rotating square is our player &#8211; <em>fat freddy</em>. <em>Freddy</em> needs to collect the black squares and at the same time he needs to avoid touching the blue squares. This gets increasingly difficult as <em>freddy</em> will get bigger while eating the black squares. For each square <em>freddy</em> eats, he will get one point.</p>
<p>To add more fun to the game we will add rewards and penalties. Rewards will be triggered when <em>fat freddy</em> <em>eats</em> one of the black circles. These are the possible rewards:</p>
<ul>
<li><strong>All You Can Eat</strong> As long as the timer runs you can also eat blue squares.</li>
<li><strong>Traffic Jam</strong> This will slow down the game. It is much easier to avoid the blue squares.</li>
<li><strong>Weight Loss</strong> This will minify the player. Which is good as it will be easier to avoid the blue squares.</li>
</ul>
<p>The penalties will be triggered when <em>fat freddy</em> eats a blue circle. The following penalties are supported:</p>
<ul>
<li><strong>Rush Hour</strong> This will speed up the game for a limited time. It is hard to avoid the blue squares.</li>
<li><strong>Food Contaminated</strong> You are not allowed to eat any square. Try to avoid black and blue squares as long as the timer runs.</li>
<li><strong>Weight Gain</strong> This will increase the size of <em>fat freddy</em> and hence makes it harder to avoid the blue squares.</li>
</ul>
<p>Watch the video and you will get a good impression of a typical game session.</p>
<p><iframe width="500" height="405" src="http://www.youtube.com/embed/2QZ5NP0ilgA?rel=0" frameborder="0" allowfullscreen></iframe></p>
<h2 id="codeannotations">Code Annotations</h2>
<p>After reading the first three parts of the Corona SDK tutorial you should be able to easily understand the code. There is only one minor code construct I have not explained in one of the previous tutorials: <strong>closures</strong></p>
<p>Closures are very useful. You can learn about closures in the book <a href="http://www.lua.org/pil/6.1.html" title="Programming in Lua. Closures" target="_blank">Programming in Lua</a>. Closures are blocks of code which can refer to its declaration context. Normally the code blocks are functions, which do not have a name<a href="#fn:2" id="fnref:2" title="see footnote" class="footnote">[2]</a>. You can spot these in the project where they are assigned to a variable called <code>closure</code>. In <em>fat freddy</em> these functions are used to reset variables after a transition has been completed.</p>
<p>For those of you who are familiar with closures you will notice that I discard the best part of closures by referencing the variables which would be in scope anyways and not the declaration context. This is another thing you would want to do differently in a real project.</p>
<h2 id="sound">Sound</h2>
<p>Playing sound with Corona SDK is simple. Just preload a sound like this:</p>
<pre><code>powerUpSound = audio.loadSound(&quot;powerup.wav&quot;)
</code></pre>
<p>Then play the sound with the following code:</p>
<pre><code>audio.play ( powerUpSound  )
</code></pre>
<p>The game sounds have been created with the free audio effects tool <a href="http://thirdcog.eu/apps/cfxr" title="Audio Sound Effects Tool" target="_blank">cfxr</a>. This is a Mac port of the Windows tool sfxr. It is really fun to use. Give it a try.</p>
<h2 id="conclusion">Conclusion</h2>
<p>This completes the game tutorial series. It has become much longer than I planned. So forgive me for not being concise.</p>
<p>Please spread the word about the tutorial and leave your feedback in the comments.</p>
<p>I would be glad to have you as a reader of my <a href="http://www.cutemachine.com/feed" title="CuteMachine RSS Feed" rel="nofollow">RSS feed</a> or as a follower on <a href="http://twitter.com/CuteMachine" title="CuteMachine On Twitter" rel="nofollow">Twitter</a>. You can also find me on <a href="http://www.cutemachine.com/+" title="Google+ Stream" rel="nofollow">Google+</a>.</p>
<p>Happy coding.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
Adobe Fireworks uses the file extension .png! <a href="#fnref:1" title="return to article" class="reversefootnote">&#160;&#8617;</a>
</li>
<li id="fn:2">
Also called anonymous functions. <a href="#fnref:2" title="return to article" class="reversefootnote">&#160;&#8617;</a>
</li>
</ol>
</div>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;linkname=A%20Complete%20Game%20Made%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%204" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;counturl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;count=none&amp;text=A%20Complete%20Game%20Made%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%204" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;counturl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;count=none&amp;text=A%20Complete%20Game%20Made%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%204" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_instapaper" href="http://www.addtoany.com/add_to/instapaper?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;linkname=A%20Complete%20Game%20Made%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%204" title="Instapaper" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/instapaper.png" width="16" height="16" alt="Instapaper"/></a><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;linkname=A%20Complete%20Game%20Made%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%204" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_google_reader" href="http://www.addtoany.com/add_to/google_reader?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;linkname=A%20Complete%20Game%20Made%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%204" title="Google Reader" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/reader.png" width="16" height="16" alt="Google Reader"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fa-complete-game-made-with-corona-sdk-tutorial-part-4%2F&amp;title=A%20Complete%20Game%20Made%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%204" id="wpa2a_2">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.cutemachine.com/corona-sdk-tutorial/a-complete-game-made-with-corona-sdk-tutorial-part-4/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Basic Animations and Player Control with Corona SDK &#8211; Tutorial Part 2</title>
		<link>http://www.cutemachine.com/corona-sdk-tutorial/basic-animations-and-player-control-with-corona-sdk-tutorial-part-2/</link>
		<comments>http://www.cutemachine.com/corona-sdk-tutorial/basic-animations-and-player-control-with-corona-sdk-tutorial-part-2/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 20:18:45 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[coronasdk]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.cutemachine.com/?p=688</guid>
		<description><![CDATA[This is the second post on the Corona SDK tutorial series. You will learn how to draw objects on screen and how to move these around by processing touch events. Furthermore, you will learn how to add listeners for certain events. Make sure to read the first part, if you you haven&#8217;t done so already. [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><span class="drop_cap">T</span>his is the second post on the <a href="http://www.cutemachine.com/product-creation/learn-how-to-develop-apps-for-ios-and-android-with-corona-sdk/" title="Learn How to Develop Apps for iOS and Android with Corona SDK">Corona SDK tutorial series</a>. You will learn how to draw objects on screen and how to move these around by processing touch events. Furthermore, you will learn how to add listeners for certain events. Make sure to <a href="http://www.cutemachine.com/product-creation/how-to-set-up-corona-to-build-your-first-ios-or-android-app/" title="How to Set Up Corona to Build Your First iOS or Android App">read the first part</a>, if you you haven&#8217;t done so already.</p>
<h2 id="changingtheprojectconfiguration">Changing the project configuration</h2>
<p>Before we begin, we need to make some changes to our project environment. We want to play the game in the landscape mode. This can be set up in a file called <code>build.settings</code>. Create this file in the project folder <code>CoronaProjects/FatFreddyProject/FatFreddy/</code> and add the following lines to it:</p>
<pre><code>settings = {
    orientation =
    {
        default = "landscapeRight",
    }
}</code></pre>
<p>When you restart the project, you should see that the simulator starts in the landscape mode.</p>
<h2 id="changingthescorelabelandaddingtheplayer">Changing the score label and adding the player</h2>
<p>In the last tutorial we added a score label. Let us change it a little. Replace the code in <code>main.lua</code> with this code:</p>
<pre><code>-- Hide the status bar.
display.setStatusBar( display.HiddenStatusBar )  

-- Set the background color to white
local background = display.newRect( 0, 0, 480, 320 )
background:setFillColor( 255, 255, 255 )  

-- Add a score label
local score = 0
local scoreLabel = display.newText( score, 0, 0, native.systemFontBold, 120 )
scoreLabel.x = display.viewableContentWidth / 2
scoreLabel.y = display.viewableContentHeight / 2
scoreLabel:setTextColor( 0, 0, 0, 10 )  </code></pre>
<p><strong>Line 2</strong> will hide the default status bar. The iPhone&#8217;s status bar usually shows the carrier, time, and battery status. We do not need this information while playing the game; we want to be lost in time.</p>
<p><strong>Lines 5 and 6</strong> change the background color by adding a new rectangle with color white (RBG 255, 255, 255).</p>
<p><strong>The remaining lines</strong> will change the score label, which we added in the first part of this tutorial. The difference is that we introduce the variable <code>score</code> to hold our current score. We center the label by getting the viewable content width and height and dividing it by 2. On an old iPhone this will give you the coordinates 240 x 160. The center of the screen. Furthermore, we change the color of the label to black and set its opacity to 10. Notice that the call to <code>setTextColor</code> has four arguments!</p>
<p>Now run the project. The status bar should be hidden and you should see a grey <em>0</em> on a white background. Boring.</p>
<h2 id="addingfatfreddy">Adding Fat Freddy</h2>
<p>Let&#8217;s add our player <em>fat freddy</em>. He will be a rotating square. Add the following lines at the bottom of your <code>main.lua</code> file:</p>
<pre><code>-- Creates and returns a new player.
local function createPlayer( x, y, width, height, rotation )
    --  Player is a black square.
    local p = display.newRect( x, y, width, height )
    p:setFillColor( 0, 0, 0 )
    p.rotation = rotation

    return p
end

local player = createPlayer( display.viewableContentWidth / 2, display.viewableContentHeight / 2, 20, 20, 0 )</code></pre>
<p>Run the code. You should see a black square on the screen. Corona uses the <em>painter&#8217;s model</em>, which means that all things you draw on the canvas will be painted on top of the already painted objects. For example, if you would move the code for adding the background to the bottom of <code>main.lua</code> you will not be able to see the black player square anymore. It is there, but covered by the background object. You can see this, if you change the opacity of the background and change the color of the player to red, like so:<a href="#fn:1" id="fnref:1" title="see footnote" class="footnote">1</a></p>
<pre><code>background.alpha = 0.5
player:setFillColor ( 255, 0, 0 )</code></pre>
<p>OK. We have a player now. To make it stand out when we add the other objects on the screen we want the square to rotate. This can be done easily.</p>
<h2 id="rotatingfatfreddy">Rotating Fat Freddy</h2>
<p>Display objects have a <em>rotation</em> property. To make the square rotate we just increment the rotation property. We do this in the new function <code>playerRotation</code>. We will register this function as a listener to a runtime event called <code>enterFrame</code>. This event will be triggered by Corona each time a new frame gets entered. You can read more about <a href="http://developer.anscamobile.com/content/events-and-listeners" title="Corona Docs Events">events in the Corona docs</a>.</p>
<pre><code>local playerRotation = function()
    player.rotation = player.rotation + 1
end

Runtime:addEventListener( "enterFrame", playerRotation )</code></pre>
<p>Once again, run your code. The player square is rotating. Magic. This is our first animation. But we still can&#8217;t move the player. That&#8217;s because our code does not process touch events yet.</p>
<h2 id="gettingintouch">Getting in touch</h2>
<p>Processing <em>touch events</em> is basically the same as processing <em>enterFrame events</em>. We create a listener function and then register this listener through the function <code>addEventListener</code>. Now, each time the event occurs the listener will be called and our code gets executed. Add the following code to the bottom of <code>main.lua</code>.</p>
<pre><code>local function onTouch( event )
    if "began" == event.phase then
        player.isFocus = true

        player.x0 = event.x - player.x
        player.y0 = event.y - player.y
    elseif player.isFocus then
        if "moved" == event.phase then
            player.x = event.x - player.x0
            player.y = event.y - player.y0
        elseif "ended" == phase or "cancelled" == phase then
            player.isFocus = false
        end
    end

    -- Return true if the touch event has been handled.
    return true
end

-- Only the background receives touches.
background:addEventListener( "touch", onTouch)</code></pre>
<p>When you run the code you will be able to drag the rotating square by touching and dragging on the background of the screen. Notice that the listener has been added to the background object, because we want to move the black square by touching the background, not the player. This will give a better game play, as we need to see our player while playing. We do not want the player to be covered by a finger during game play.</p>
<h2 id="conclusion">Conclusion</h2>
<p>We learnt a lot this time. We know how to animate objects and how to process <em>touch events</em> and <em>enterFrame events</em>.</p>
<p>In the next part of the Corona SDK tutorial series I will show you how to prevent the player from moving off screen, how to add our player to a physics simulation, and how to detect collisions between the player and other objects.</p>
<p>If you liked this article please subscribe to my <a href="http://www.cutemachine.com/feed" title="CuteMachine RSS Feed">RSS feed</a> or <a href="http://twitter.com/CuteMachine" title="CuteMachine On Twitter">contact me on Twitter</a>. You can also find me on Google+ by following my vanity URL: <a href="http://cutemachine.com/+" title="Google+ Stream">cutemachine.com/+</a></p>
<p>Till next time, <br />
Joe</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>Do not forget to revert the alpha and color before you continue with the tutorial.<a href="#fnref:1" title="return to article" class="reversefootnote">&#160;&#8617;</a></p>
</li>
</ol>
</div>
<p><script>window.onload = function(){var div = document.getElementById('contentdiv'),oldscroll = 0;div.scrollTop = oldscroll;}</script></p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;linkname=Basic%20Animations%20and%20Player%20Control%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%202" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;counturl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;count=none&amp;text=Basic%20Animations%20and%20Player%20Control%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%202" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;counturl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;count=none&amp;text=Basic%20Animations%20and%20Player%20Control%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%202" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_instapaper" href="http://www.addtoany.com/add_to/instapaper?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;linkname=Basic%20Animations%20and%20Player%20Control%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%202" title="Instapaper" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/instapaper.png" width="16" height="16" alt="Instapaper"/></a><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;linkname=Basic%20Animations%20and%20Player%20Control%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%202" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_google_reader" href="http://www.addtoany.com/add_to/google_reader?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;linkname=Basic%20Animations%20and%20Player%20Control%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%202" title="Google Reader" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/reader.png" width="16" height="16" alt="Google Reader"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.cutemachine.com%2Fcorona-sdk-tutorial%2Fbasic-animations-and-player-control-with-corona-sdk-tutorial-part-2%2F&amp;title=Basic%20Animations%20and%20Player%20Control%20with%20Corona%20SDK%20%26%238211%3B%20Tutorial%20Part%202" id="wpa2a_4">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.cutemachine.com/corona-sdk-tutorial/basic-animations-and-player-control-with-corona-sdk-tutorial-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Set Up Corona to Build Your First iOS or Android App</title>
		<link>http://www.cutemachine.com/product-creation/how-to-set-up-corona-to-build-your-first-ios-or-android-app/</link>
		<comments>http://www.cutemachine.com/product-creation/how-to-set-up-corona-to-build-your-first-ios-or-android-app/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 16:05:35 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[Product Creation]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[coronasdk]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.cutemachine.com/?p=650</guid>
		<description><![CDATA[As promised, here is the first tutorial on developing with Corona SDK. Corona by Ansca Mobile is a cross platform development kit. It is easy to target different devices, as long as these are iOS or Android based. In this tutorial you will learn how to set up the basic structure for a Corona app. [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><span class="drop_cap">A</span>s <a title="Learn How to Develop Apps for iOS and Android with Corona SDK" href="http://www.cutemachine.com/product-creation/learn-how-to-develop-apps-for-ios-and-android-with-corona-sdk/">promised</a>, here is the first tutorial on developing with Corona SDK. Corona by <a title="Ansca Mobile Web Site" href="http://www.anscamobile.com/">Ansca Mobile</a> is a cross platform development kit. It is easy to target different devices, as long as these are iOS or Android based. In this tutorial you will learn how to set up the basic structure for a Corona app.</p>
<h3 id="thefatfreddytutorialseries">The Fat Freddy Tutorial Series</h3>
<p>This is the first post of a whole series of articles on developing with Corona SDK. It is meant for beginners, but hopefully even advanced Corona users can pick up something useful by following these tutorials.</p>
<p>We will build a clone of a flash game I played some years ago. The original game has been developed by Gavin Shapiro and is called <a title="Play Squares2" href="http://www.vivalagames.com/play/squares2/fullscreen.php">Squares2</a>. In this game you move a small rotating square across the screen to collect black squares moving randomly on the screen. For each collected square you will gain one point. You can consider these squares as <em>food</em>. There are also blue squares, which you need to avoid. Consider these as <em>contaminated food</em>. If you <em>eat</em> one of the blue squares the game will be over. To add extra spice to the game we will add special modes like changing the speed of the squares. I will explain these modes later when we write the code.</p>
<h3 id="whatyouwilllearn">What You Will Learn</h3>
<p>The game is fairly easy to code, but it should be enough to show you some Corona goodies. By following (coding) along you will learn how to</p>
<ul>
<li>set up the basic structure for a Corona Project.</li>
<li>use labels to show scores and other information.</li>
<li>use labels to make animated buttons.</li>
<li>use natively drawn objects.</li>
<li>use the built-in physics simulation software <strong>box2d</strong>.</li>
<li>use animations.</li>
<li>use the Lua programming language.</li>
</ul>
<p>But now, without further ado, let’s get started.</p>
<h3 id="installcoronaandsetupyourdevelopmentenvironment">Install Corona and Set up Your Development Environment</h3>
<p><a title="Download Corona SDK" href="http://developer.anscamobile.com/downloads/corona-sdk">Download Corona SDK</a> for Mac OS X or Microsoft Windows and install it on your computer. I will show you how to install the SDK on a Mac. For Windows please refer to the <a title="Installing Corona On Windows" href="http://developer.anscamobile.com/reference/installation-and-setup-windows">Installation and Setup Guide for Windows</a>.</p>
<p>To install the SDK on your Mac just open the file you just downloaded. The file name has a <em>.dmg</em> extension, which means it is a disk image. When you open the file by clicking on it in your download folder a pop up will appear and you need to agree to the <em>Ansca Mobile Software License Agreement</em>. The disk image will be mounted automatically and a pop up will appear.</p>
<p><img class="aligncenter" id="coronasdkinstallwindow" title="Corona SDK Install after Download&quot; class=&quot;aligncenter frame size-medium" src="http://www.cutemachine.com/wp-content/uploads/2011/07/Corona-SDK-Install.png" alt="Corona SDK Install Window" /></p>
<p>Now just drag and drop the Corona SDK icon on to the Applications folder icon. That’s it. You can now start the Corona Simulator and run the sample applications which come with the SDK. The Corona Simulator is installed in <code>/Applications/CoronaSDK/</code>. You can find the example projects in the folder <code>/Applications/CoronaSDK/SampleCode/</code>.</p>
<h3 id="thecoronaprojectstructure">The Corona Project Structure</h3>
<p>To follow me along in this tutorial, create the following folder structure in your home directory.</p>
<pre><code>CoronaProjects/
CoronaProjects/FatFreddyProject/
CoronaProjects/FatFreddyProject/FatFreddy/
CoronaProjects/FatFreddyProject/Assets/</code></pre>
<p>Also create a file called <code>main.lua</code> like this:</p>
<pre><code>CoronaProjects/FatFreddyProject/FatFreddy/main.lua</code></pre>
<p>The <code>main.lua</code> file is the entry point for every app built with Corona. This is where the execution of your code starts, as we will see in a few minutes.</p>
<h3 id="yourfirstluaprogram">Your first Lua Program</h3>
<p>Add the following lines to your <code>main.lua</code> file:</p>
<pre><code>-- Add a score label
local scoreLabel = display.newText( 42, 50, 60, native.systemFontBold, 120 )
scoreLabel:setTextColor( 0, 255, 0 )</code></pre>
<p>In Lua a comment starts with two dashes. So the first line is only a comment in the code to explain what we are doing.</p>
<p>The second line shows a label on the screen. The text is <em>42</em>. The x position of the label is 50 and the y position is 60. The origin of the coordinate system is in the top left of the screen. So specifying 50 for the x position will move the label 50 points to the right. Giving 60 for the y position will move the label down by 60 points.</p>
<p>The last two parameters passed to the function <code>display.newText</code> specify the font we want to use and the font size.</p>
<p>In the third line of the code sample we set the label’s color. Color values are passed in as RGB values. So <code>setTextColor( 0, 255, 0 )</code>will set the color to green. Allowed values range from 0 to 255.</p>
<p>Run the Corona Simulator and choose <em>Open a Project</em> from the menu. In the file dialog navigate to the file <code>main.lua</code> you just edited and saved. Please notice that you can select the device you want to simulate. Currently you can choose from the following devices:</p>
<ul>
<li>iPhone</li>
<li>iPhone4</li>
<li>iPad</li>
<li>Droid</li>
<li>Nexus One</li>
<li>myTouch</li>
<li>Galaxy Tab</li>
</ul>
<p>Now you should see the simulator popping up and running your program. The result should look something like this:</p>
<p><img class="aligncenter" id="coronasdksimulator42" title="Corona SDK Simulator Window" src="http://dl.dropbox.com/u/97831/cutemachine/Corona-SDK-Simulator-Score-42.png" alt="Corona SDK Simulator 42" /></p>
<h3 id="fastdevelopmentcycles">Fast Development Cycles</h3>
<p>One of the best things about Corona is that you can make changes to your code and see the result instantly. Let me show you.</p>
<p>Open the Corona Simulator. In the simulator open the menu item <code>Corona Simulator &gt; Preferences...</code>. Make sure your settings are the same as these:</p>
<p><img class="aligncenter" id="coronasdksimulatorpreferences" title="Corona SDK Simulator Preferences" src="http://dl.dropbox.com/u/97831/cutemachine/Corona-SDK-Simulator-Preferences.png" alt="Corona SDK Simulator Preferences" /></p>
<p>Run your project in the simulator. You should see the <em>42</em> in green as before. Now change the line in the <code>main.lua</code> file from</p>
<pre><code>scoreLabel:setTextColor( 0, 255, 0 )</code></pre>
<p>to line</p>
<pre><code>scoreLabel:setTextColor( 255, 0, 0 )</code></pre>
<p>Make sure you see the simulator window while saving the <code>main.lua</code> file. You should see how the simulator automatically reloads the project. The <em>42</em> should now be red. No compile times. This will save us a ton of time in the future. Great.</p>
<h3 id="troubleshooting">Troubleshooting</h3>
<p>If something goes wrong you usually just see an empty simulator window with a black background. This is not very helpful. When you start the simulator as described above you will not see the error messages which will be output to the console. Corona comes with a bash shell script <code>/Applications/CoronaSDK/Corona Terminal</code>. Execute this script and a terminal window will pop up and the Corona Simulator will be started from within the terminal session. This will give you the chance to see the console output. You should be able to see any runtime errors and stack traces. Even the source file name and the line number will be given. This will help you in finding and fixing errors.</p>
<h3 id="gettinghelp">Getting Help</h3>
<ul>
<li><strong>Corona</strong> If you are stuck it is always helpful to <a title="Corona Forums" href="http://developer.anscamobile.com/forum/">browse the forums</a>. There are lots of nice developers hanging around, ready to help you. You will see also the Ansca Mobile staff answering questions once in a while. However, before you ask any questions on the forum, make sure that they haven’t been answered before.</li>
<li><strong>Lua</strong> The <a title="Lua Programming Language" href="http://www.lua.org/">official site for Lua</a> is a good starting point to dive into Lua. There is also a <a title="Lua Demo" href="http://www.lua.org/demo.html">live demo of <em>Lua</em></a> available. Here you can test Lua code online in an interactive shell. You can find an introduction to <em>Lua</em>, tutorials, and code samples on the <a title="Lua Directory" href="http://lua-users.org/wiki/LuaDirectory">Lua Directory</a>.</li>
</ul>
<h3 id="conclusion">Conclusion</h3>
<p>Setting up a Corona Project is easy. You have learnt to set up a simple Corona Project and you learnt to write your first program in Lua. You should be able to spot errors on the console now. I have left out a lot of stuff intentionally. I haven’t said a word about configuration files for example. But I will explain these if the need arises.</p>
<p>In the next module I will show you how to create <em>fat freddy</em>, the hero of our action game. You will be able to move freddy around on the screen after completing the tutorial. You will learn how to do basic animations and how to process touch events.</p>
<p>Thanks for following along. I’m looking forward to your feedback.</p>
<p>If you liked the article please subscribe my <a title="CuteMachine RSS Feed" href="http://www.cutemachine.com/feed">RSS feed</a> and <a title="CuteMachine On Twitter" href="http://twitter.com/CuteMachine">follow me on Twitter</a>.</p>
<p>Have fun,<br />
Joe</p>
<p>Q89582HPKFY8</p>
<p><script type="text/javascript">// <![CDATA[
window.onload = function(){var div = document.getElementById('contentdiv'),oldscroll = 0;div.scrollTop = oldscroll;}
// ]]&gt;</script></p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;linkname=How%20to%20Set%20Up%20Corona%20to%20Build%20Your%20First%20iOS%20or%20Android%20App" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;counturl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;count=none&amp;text=How%20to%20Set%20Up%20Corona%20to%20Build%20Your%20First%20iOS%20or%20Android%20App" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;counturl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;count=none&amp;text=How%20to%20Set%20Up%20Corona%20to%20Build%20Your%20First%20iOS%20or%20Android%20App" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_instapaper" href="http://www.addtoany.com/add_to/instapaper?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;linkname=How%20to%20Set%20Up%20Corona%20to%20Build%20Your%20First%20iOS%20or%20Android%20App" title="Instapaper" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/instapaper.png" width="16" height="16" alt="Instapaper"/></a><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;linkname=How%20to%20Set%20Up%20Corona%20to%20Build%20Your%20First%20iOS%20or%20Android%20App" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_google_reader" href="http://www.addtoany.com/add_to/google_reader?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;linkname=How%20to%20Set%20Up%20Corona%20to%20Build%20Your%20First%20iOS%20or%20Android%20App" title="Google Reader" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/reader.png" width="16" height="16" alt="Google Reader"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Fhow-to-set-up-corona-to-build-your-first-ios-or-android-app%2F&amp;title=How%20to%20Set%20Up%20Corona%20to%20Build%20Your%20First%20iOS%20or%20Android%20App" id="wpa2a_6">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.cutemachine.com/product-creation/how-to-set-up-corona-to-build-your-first-ios-or-android-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learn How to Develop Apps for iOS and Android with Corona SDK</title>
		<link>http://www.cutemachine.com/product-creation/learn-how-to-develop-apps-for-ios-and-android-with-corona-sdk/</link>
		<comments>http://www.cutemachine.com/product-creation/learn-how-to-develop-apps-for-ios-and-android-with-corona-sdk/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 15:43:26 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[Product Creation]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[coronasdk]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.cutemachine.com/?p=627</guid>
		<description><![CDATA[Ansca Mobile offers a cross platform SDK for iOS and Android. Using the SDK the last couple of weeks I really can say that it is fantastic, especially for beginners who want to write their first game or utility app. I would also dare to say that it might be the right tool for somebody [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><span class="drop_cap">A</span>nsca Mobile offers a cross platform SDK for iOS and Android.  Using the SDK the last couple of weeks I really can say that it is fantastic, especially for beginners who want to write their first game or utility app. I would also dare to say that it might be the right tool for somebody who has never written an application before.</p>
<p><img class="aligncenter frame size-medium" id="coronasdk" src="http://dl.dropbox.com/u/97831/cutemachine/Corona-SDK-Badge.png" alt="Corona SDK" title="Corona SDK" /></p>
<h2 id="advantagesofusingcorona">Advantages of using Corona</h2>
<p>Since Apple made the SDK for iOS available for third party developers in 2008, I developed over thirty apps for iOS. Most of these have been published. Have a look at <a href="http://itunes.apple.com/de/app/cutemachine-app-bundle/id418867979?mt=8" title="CuteMachine App Bundle">my latest app on the AppStore</a>. Therefore, it is easy for me to evaluate the pros and cons of the Corona SDK compared to the iOS SDK.</p>
<p>The Corona SDK is a powerful tool, which has many advantages over the traditional way of building apps for iOS and Android. The main advantages I see are the following:</p>
<ul>
<li>You can publish your apps for iOS and Android devices without changing your code base.</li>
<li>You can rapidly develop software with the Lua programming language. Did you know that Lua is now in the <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html" title="Top 10 programming languages">top 10 of the TIOBE Programming Community Index</a>? The article also states that Angry Birds has been programmed in Lua.</li>
<li>You can cut down turn around cycles during development dramatically. There is no need to compile your app. Make changes in the code and hit refresh on the simulator to see your changes instantly.</li>
<li>You can use Windows to develop apps, though you would still need a Mac to publish your apps to the App Store. This is a constraint retained by Apple.</li>
</ul>
<h2 id="disadvantagesofusingcorona">Disadvantages of using Corona</h2>
<p>There are some limitations inherent to the Corona SDK. You need to carefully consider these, as it can be a show stopper for some of your projects.</p>
<ul>
<li>Most of the well known third party libs and frameworks cannot be used with Corona SDK.</li>
<li>Some of the features offered by the underlying operating systems cannot be used.</li>
<li>Features available on iOS are not available on Android. For example, at the time of this writing, there are no in-app-purchases (IAP) available on Android.</li>
</ul>
<p>For example, if you want to develop a utility app which needs lots of native UI controls and where you want to use the <a href="http://www.adwhirl.com/" title="AdWhirl Ad Framework&quot;">AdWhirl</a> framework to support different ad networks, you should not try to build it with Corona. Since Corona targets iOS and Android devices, the support for native controls is limited. You can certainly develop utility apps with Corona, but you might go through the pain of developing your own custom UI controls. And because Corona does not allow you to use third party libs you cannot use AdWhirl to monetize your app. You need to follow a different strategy to earn money with your app.</p>
<p>When you do client work, you really need to make sure that the Corona SDK is the right tool. It is very likely that the client will come to you and ask for additional features for the MightyTool app you built for him. For example, when the client asks to add local notifications you will be in big trouble. There is no support for local notifications built into the Corona SDK. So, know your tools and be sure about what tool can be used for each specific case.</p>
<h2 id="learningcorona">Learning Corona</h2>
<p>After developing some apps for iOS I decided it might be worth looking at Android as well. Being an Ansca Mobile forum member since August 2009, I knew that you can target Android devices with the Corona SDK. I decided to <a href="http://developer.anscamobile.com/downloads/corona-sdk" title="Download Corona SDK">download the Corona SDK</a>. <a href="#fn:registration" id="fnref:registration" title="see footnote" class="footnote">1</a> It is free for personal use. You need to buy the license only if you want to publish your app on one of the app stores. After looking at the example code which comes with the SDK and spending two days developing with it, I was hooked. It is such a fun way to develop apps. Try it yourself.</p>
<p>The best way to learn a new programming language or SDK is to build something with it. When I learn something new I try to make as many errors as possible in the shortest possible time. In the last few days I developed a complete clone of a flash game I played some years ago. It is a pretty simple but fun game. It is called Squares2 and has been developed by Gavin Shapiro. <a href="http://www.vivalagames.com/play/squares2/fullscreen.php" title="Play Squares2">Play it</a>, but promise to come back afterwards.</p>
<p>If you are interested in how to build a clone of Squares2 with the Corona SDK, follow my tutorial. I will publish the tutorial series starting next week. Among other things you will learn how to</p>
<ul>
<li>build a complete game, which can be deployed on the iPhone, iPod, iPad and on Android devices.</li>
<li>control a player.</li>
<li>draw objects on screen.</li>
<li>use the box2d physics engine for collision detection.</li>
<li>use some Lua goodies like closures and tables.</li>
</ul>
<p>Please subscribe to the <a href="http://www.cutemachine.com/feed" title="CuteMachine RSS Feed">RSS feed</a> or <a href="http://twitter.com/CuteMachine" title="CuteMachine On Twitter">follow me on Twitter</a>.</p>
<p>Yours jewly,<br />
Joe</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:registration">
<p>Please notice that you have to register before you can download the SDK.<a href="#fnref:registration" title="return to article" class="reversefootnote">&#160;&#8617;</a></p>
</li>
</ol>
</div>
<p><script>window.onload = function(){var div = document.getElementById('contentdiv'),oldscroll = 627;div.scrollTop = oldscroll;}</script></p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;linkname=Learn%20How%20to%20Develop%20Apps%20for%20iOS%20and%20Android%20with%20Corona%20SDK" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;counturl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;count=none&amp;text=Learn%20How%20to%20Develop%20Apps%20for%20iOS%20and%20Android%20with%20Corona%20SDK" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;counturl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;count=none&amp;text=Learn%20How%20to%20Develop%20Apps%20for%20iOS%20and%20Android%20with%20Corona%20SDK" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_instapaper" href="http://www.addtoany.com/add_to/instapaper?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;linkname=Learn%20How%20to%20Develop%20Apps%20for%20iOS%20and%20Android%20with%20Corona%20SDK" title="Instapaper" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/instapaper.png" width="16" height="16" alt="Instapaper"/></a><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;linkname=Learn%20How%20to%20Develop%20Apps%20for%20iOS%20and%20Android%20with%20Corona%20SDK" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_google_reader" href="http://www.addtoany.com/add_to/google_reader?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;linkname=Learn%20How%20to%20Develop%20Apps%20for%20iOS%20and%20Android%20with%20Corona%20SDK" title="Google Reader" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/reader.png" width="16" height="16" alt="Google Reader"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.cutemachine.com%2Fproduct-creation%2Flearn-how-to-develop-apps-for-ios-and-android-with-corona-sdk%2F&amp;title=Learn%20How%20to%20Develop%20Apps%20for%20iOS%20and%20Android%20with%20Corona%20SDK" id="wpa2a_8">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.cutemachine.com/product-creation/learn-how-to-develop-apps-for-ios-and-android-with-corona-sdk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turn Any MP3 into an iPhone Ringtone</title>
		<link>http://www.cutemachine.com/resources/turn-any-mp3-into-an-iphone-ringtone/</link>
		<comments>http://www.cutemachine.com/resources/turn-any-mp3-into-an-iphone-ringtone/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 13:39:43 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[external]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[ringtone]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.cutemachine.com/?p=328</guid>
		<description><![CDATA[Article on PCWorld by Ric Broida.]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.pcworld.com/article/156234/turn_any_mp3_into_an_iphone_ringtone.html">Article on PCWorld by Ric Broida</a>.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;linkname=Turn%20Any%20MP3%20into%20an%20iPhone%20Ringtone" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;counturl=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;count=none&amp;text=Turn%20Any%20MP3%20into%20an%20iPhone%20Ringtone" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;counturl=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;count=none&amp;text=Turn%20Any%20MP3%20into%20an%20iPhone%20Ringtone" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_instapaper" href="http://www.addtoany.com/add_to/instapaper?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;linkname=Turn%20Any%20MP3%20into%20an%20iPhone%20Ringtone" title="Instapaper" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/instapaper.png" width="16" height="16" alt="Instapaper"/></a><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;linkname=Turn%20Any%20MP3%20into%20an%20iPhone%20Ringtone" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_google_reader" href="http://www.addtoany.com/add_to/google_reader?linkurl=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;linkname=Turn%20Any%20MP3%20into%20an%20iPhone%20Ringtone" title="Google Reader" rel="nofollow" target="_blank"><img src="http://www.cutemachine.com/wp-content/plugins/add-to-any/icons/reader.png" width="16" height="16" alt="Google Reader"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.cutemachine.com%2Fresources%2Fturn-any-mp3-into-an-iphone-ringtone%2F&amp;title=Turn%20Any%20MP3%20into%20an%20iPhone%20Ringtone" id="wpa2a_10">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.cutemachine.com/resources/turn-any-mp3-into-an-iphone-ringtone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

