<?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>WebDevTutsDepot &#187; Corona SDK</title>
	<atom:link href="http://webtutsdepot.com/category/mobile-development/corona-sdk/feed/" rel="self" type="application/rss+xml" />
	<link>http://webtutsdepot.com</link>
	<description>Web Development Tutorials</description>
	<lastBuildDate>Mon, 02 Jan 2012 02:28:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Corona SDK Tutorial: How To Add Images</title>
		<link>http://webtutsdepot.com/2011/12/04/corona-sdk-tutorial-how-to-add-images/</link>
		<comments>http://webtutsdepot.com/2011/12/04/corona-sdk-tutorial-how-to-add-images/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 06:02:03 +0000</pubDate>
		<dc:creator>Carlos</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://webhole.net/?p=2343</guid>
		<description><![CDATA[Learn to work with images to add them to your apps or games.]]></description>
				<content:encoded><![CDATA[<p></p><p>When submitting an image in Corona SDK we must use the function newImage of the display object. This function takes two parameters</p>
<ul>
<li>filename</li>
<li>left corner (x-coordinate)</li>
<li>top (left) corner(y-coordinate)</li>
</ul>
<h3>config.lua</h3>
<p>First let&#8217;s make a config file to set the screen size.</p>
<pre>application =
{
     content =
     {
        width = 320,
        height = 480,
        scale = "zoomEven"
      }
}</pre>
<h3>main.lua</h3>
<p>Now lets work on the main.lua file. We can store the image in a variable and use that variable later to change other properties of that image like its position, and its size. To use this image we must also save it in the same folder as the main.lua file.</p>
<p>Let&#8217;s insert an image called &#8220;image_variable_name&#8221;</p>
<pre>
--object= display.newImage(filename)
image_variable_name = display.newImage( "testimage.jpg" )
</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Image inserted with the code above" src="https://lh5.googleusercontent.com/-CUaydLfoXDE/Ttrm8YZ1htI/AAAAAAAAAII/phHaMHdRT6E/s800/testimage.jpg" width="308" height="588" />
	<p class="wp-caption-text">Image inserted with the code above</p>
</div>
<p>You can also change the position of the image by inserting two points after the file name separated by a comma. The first point will be the x-coordinate, and the second the y-coordinate. These points will determine the top left corner of the image.</p>
<pre>
--object= display.newImage(filename, x-coordinate, y-coordinate)
image_variable_name = display.newImage( "testimage.jpg", 160, 240 )
</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Image With Different Position" src="https://lh4.googleusercontent.com/-Rm3KEVGsXHU/Ttrpkwu2bbI/AAAAAAAAAIg/xdUlgeQjBfM/s800/testimage_change_position.jpg" width="308" height="588" />
	<p class="wp-caption-text">Image with a different x and y coordinate</p>
</div>
<p>Another thing you could do with this image is change its size with the function scale  of the display object. We will scale this image by half with the following function</p>
<pre>
--object:scale( fx, sy )
image_variable_name:scale( .5, .5)
</pre>
<p>The first .5 represents the factor by which the x direction is scaled, the same thing goes for the second number, but this one represents the y direction. In this example the image was scaled by a factor of 50%, if you wanted to scale it by a factor of 200% you could have used a 2 instead of a .5</p>
<p>The full code for this scaled image will be.</p>
<pre>
image_variable_name = display.newImage( "testimage.jpg", 0, 0 )
image_variable_name:scale( .5, .5)
</pre>
<p><div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Scaled Image" src="https://lh4.googleusercontent.com/-uYY2VGMvFyo/TtrtbmMP5_I/AAAAAAAAAI4/dhe2u0VBjG8/s800/testimage_scaled.jpg" width="308" height="588" />
	<p class="wp-caption-text">Scaled image with the code above</p>
</div><br />
One thing you might have noticed is that when you scaled the image the top left corner is not where you told it to be, to fix this you are going to have to play with the numbers.</p>
<p>Now, to rotate the image you are going to use the function rotate of the display object. We are going to rotate this image at a 130 degree angle with the following function</p>
<pre>
--object:rotate( Angle(+ or -) )
image_variable_name:rotate( 130 )
</pre>
<p>The full code for the rotated image is.</p>
<pre>
image_variable_name = display.newImage( "testimage.jpg", -100, 0 )
image_variable_name:scale( .5, .5)
image_variable_name:rotate( 130 )
</pre>
<p><div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Rotate Image" src="https://lh3.googleusercontent.com/-0BmpC21Nw4Y/TtrxYV0bA_I/AAAAAAAAAJQ/q7hOH_vaPq0/s800/testimage_rotate.jpg" width="308" height="588" />
	<p class="wp-caption-text">Rotated  Image from the code above</p>
</div><br />
Adding a positive angle will cause the image to rotate clockwise, and adding a negative angle will cause it to rotate counter clock wise. You can also repeat the same image more than one time, there are times when you do not need to rename the image you repeated, but for this example we will in case we want to change the properties of only that image.</p>
<pre>
fisherman1 = display.newImage( "testimage.jpg", -100, 0 )
fisherman1:scale( 2, 2)
fisherman1:rotate( 180 )

fisherman2 = display.newImage( "testimage.jpg", -100, 0 )
fisherman2:scale( 1, 1)
fisherman2:rotate( 160 )

fisherman3 = display.newImage( "testimage.jpg", -100, 0 )
fisherman3:scale( .5, .5)
fisherman3:rotate( 140 )

fisherman4 = display.newImage( "testimage.jpg", -100, 0 )
fisherman4:scale( .4, .4)
fisherman4:rotate( 120 )

fisherman5 = display.newImage( "testimage.jpg", -100, 0 )
fisherman5:scale( .3, .3)
fisherman5:rotate( 100 )

fisherman6 = display.newImage( "testimage.jpg", -100, 0 )
fisherman6:scale( .2, .2)
fisherman6:rotate( 80 )

fisherman7 = display.newImage( "testimage.jpg", -100, 0 )
fisherman7:scale( .1, .1)
fisherman7:rotate( 60 )
</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Copied and Rotated Image" src="https://lh6.googleusercontent.com/-LkBjEGQ4FRs/Ttr0XTniUrI/AAAAAAAAAJo/X6sz9Fnxtmk/s800/multiple_testimage_rotate.jpg" width="308" height="588" />
	<p class="wp-caption-text">Same image copied and rotated several times</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://webtutsdepot.com/2011/12/04/corona-sdk-tutorial-how-to-add-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Corona SDK Tutorial:How Work With Text</title>
		<link>http://webtutsdepot.com/2011/11/30/corona-sdk-tutorial-text/</link>
		<comments>http://webtutsdepot.com/2011/11/30/corona-sdk-tutorial-text/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 02:03:07 +0000</pubDate>
		<dc:creator>Carlos</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://webhole.net/?p=2311</guid>
		<description><![CDATA[Learn to work with generated text in Corona SDK]]></description>
				<content:encoded><![CDATA[<p></p><p>When creating text in Corona SDK we must use the function newText of the display object. This function takes four parameter</p>
<ul>
<li>string</li>
<li>left corner (x-coordinate)</li>
<li>top (left) corner(y-coordinate)</li>
</ul>
<h3>config.lua</h3>
<p>First let&#8217;s make a config file to set the screen size.</p>
<pre>application =
{
     content =
     {
        width = 320,
        height = 480,
        scale = "zoomEven"
      }
}</pre>
<h3>main.lua</h3>
<p>Now lets work on the main.lua file. We can store the text in a variable and use that variable later to change other properties of that text like the color, size, and font.</p>
<p>In our text, the coordinates that we give it are for the top left corner. Now let&#8217;s make a text called &#8220;text_variable_name&#8221; with the top left corner at (160,240).</p>
<pre>--local nameoftext = display.newText(string,left-x-coordinate,top-y-coordinate)
local text_variable_name = display.newText("WebHole", 160, 240)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh6.googleusercontent.com/-2uCIry1JowM/Ttbn_Pp3bjI/AAAAAAAAAHU/RHw5-sHsmGk/s800/White_text.jpg" alt="White text" width="308" height="588" />
	<p class="wp-caption-text">White text from the code above</p>
</div>
<p>I created two white lines to point at this coordinate however, they are not necessary.</p>
<p>The default color of the text is white, let&#8217;s change the color to red using the setTextColor function. The setTextColor function also needs three parameters which range from 0 to 250 in this order:</p>
<ul>
<li>amount of red</li>
<li>amount of green</li>
<li>and amount of blue</li>
</ul>
<pre>--nameoftext:setTextColor(Red, Green, Blue)
text_variable_name:setTextColor(255,0,0)</pre>
<p>The full code for the text is</p>
<pre>local text_variable_name = display.newText("WebHole", 160, 240)
text_variable_name:setTextColor(255,0,0)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh4.googleusercontent.com/-UCm2px5_nrM/TtbrN55mm-I/AAAAAAAAAHc/ozm6qjcqmbE/s800/red_text.jpg" alt="Red text" width="308" height="588" />
	<p class="wp-caption-text">Red text from the code above</p>
</div>
<p>Now we will change the size of our text. For our next example we will create two different variable names of different colors to see the difference in size. To change the size we will add two more parameter to the</p>
<pre>display.newText</pre>
<p> function, one will be the font, and the other will be the size which we will set to 30.</p>
<pre>--local nameoftext = display.newText(string,left-x-coordinate,top-y-coordinate,font,size)
local Green_Text = display.newText("WebHole", 160, 240,native.systemFont,30)
Green_Text:setTextColor(0, 250, 0)
local Red_Text = display.newText("WebHole", 160, 240)
Red_Text:setTextColor(250, 0, 0)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh4.googleusercontent.com/-joipjtWYJA0/Ttbn-mUTouI/AAAAAAAAAHU/NFzCFL6f300/s800/Red_Green_Text_size.jpg" alt="increasing size" width="308" height="588" />
	<p class="wp-caption-text">Increasing the size of the text from our original text</p>
</div>
<p>When you entered this code you noticed that the font size changed diagonally, and the coordinate of the top left corner stayed where we placed it. In our next example we have the function</p>
<pre>nameoftext.size = number</pre>
<p>that will also change the size of the text however, the size will grow in all directions(not diagonally like in our previous example).We will color this new text yellow.</p>
<pre>local Yellow_Text = display.newText("WebHole", 160, 240,native.systemFont)
Yellow_Text:setTextColor(250, 250, 0)

--nameoftext.size = number
Yellow_Text.size = 30

local Red_Text = display.newText("WebHole", 160, 240)
Red_Text:setTextColor(250, 0, 0)</pre>
<p><div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Yellow Text" src="https://lh6.googleusercontent.com/-zLSF01Jl_Ko/Ttbn-1pwqcI/AAAAAAAAAHU/fbDCDICBy5o/s800/Red_yellow_Green_Text_size.jpg" width="308" height="588" />
	<p class="wp-caption-text">New text compared to the previous ones</p>
</div><br />
You can also increase the size diagonally after it has increased in all directions by typing a number for size in
<pre>local nameoftext = display.newText(string,left-x-coordinate,top-y-coordinate,font,size)</pre>
<p> and then increase the size outward by adding a number in the function
<pre>nameoftext.size = number</pre>
<p>. Another function we could use with the text function is nameoftext.text = string. And instead of typing a string inside the &quot; &quot; in the
<pre>display.newText</pre>
<p> function, we will type it in for the string in
<pre>nameoftext.text = string</pre>
<p>. This will cause the x and y coordinates you choose to be in the center of your text, not in the top left corner.</p>
<pre>local Green_Text = display.newText("", 160, 240)
Green_Text:setTextColor(0, 250, 0)

--nameoftext.text = string
Green_Text.text = "WebHole"

local Red_Text = display.newText("WebHole", 160, 240)
Red_Text:setTextColor(250, 0, 0)</pre>
<p><div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Centered text" src="https://lh5.googleusercontent.com/-jaC7c8cRFoM/Ttbn-oTERjI/AAAAAAAAAHU/Z2Z_lhgO8JY/s800/Red_Green_Text_center.jpg" width="308" height="588" />
	<p class="wp-caption-text">With our new function, the x and y coordinates of the green text you chose are in the center of your text, not in the top left corner.</p>
</div><br />
You can then change the size of the text with the functions we learned above:</p>
<pre>local Yellow_Text = display.newText("WebHole", 160, 240,native.systemFont,50)
Yellow_Text:setTextColor(250, 250, 0)

Yellow_Text.size = 30

local Green_Text = display.newText("", 160, 240,native.systemFont,50)
Green_Text:setTextColor(0, 250, 0)

Green_Text.size = 60
Green_Text.text = "WebHole"

local Red_Text = display.newText("WebHole", 160, 240)
Red_Text:setTextColor(250, 0, 0)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Centered Text" src="https://lh6.googleusercontent.com/-i54C4I6FN04/Ttbn-WiS_GI/AAAAAAAAAHU/Kau44mn1ulY/s800/Different_Text_Size_color.jpg" width="308" height="588" />
	<p class="wp-caption-text">Different types of text grouped.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://webtutsdepot.com/2011/11/30/corona-sdk-tutorial-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Corona SDK Tutorial: How To Work With Lines</title>
		<link>http://webtutsdepot.com/2011/11/29/corona-sdk-tutorial-how-to-work-with-lines/</link>
		<comments>http://webtutsdepot.com/2011/11/29/corona-sdk-tutorial-how-to-work-with-lines/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 03:05:22 +0000</pubDate>
		<dc:creator>Carlos</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://webhole.net/?p=2272</guid>
		<description><![CDATA[Continuing with our Corona SDK Tutorial series, in this post we show you how to use the line object function.]]></description>
				<content:encoded><![CDATA[<p></p><p>When we create a line in Corona SDK we must use the function newLine of the display object, takes four parameters in this order:</p>
<ul>
<li>first x-coordinate (x1)</li>
<li>first y-coordinate(y1)</li>
<li>second x-coordinate(x2)</li>
<li>second y-coordinate(y2)</li>
</ul>
<div>where the first set of x1 and y1 define where the line starts and the next set (x2,y2) define where it ends.</div>
<h3>config.lua</h3>
<p>First let&#8217;s make a config file to set the screen size.</p>
<pre>application =
{
     content =
     {
        width = 320,
        height = 480,
        scale = "zoomEven"
      }
}</pre>
<h3>main.lua</h3>
<p>Now we will work on the main.lua file. We will store the line in a variable and use that variable later to change other properties of it like the color, the width of the line, length of the line and the number of extra segments connected to that line.</p>
<p>Let&#8217;s make a line called &#8220;line_variable_name&#8221; with the coordinates at (170,400)  &amp;  (200,300)</p>
<pre>--local nameofline = display.newLine(x1, y1, x2, y2)
local line_variable_name = display.newLine(170, 400, 200, 300)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh5.googleusercontent.com/-P-XRZC-E8Mk/TtWUHmhdMbI/AAAAAAAAAFI/8ipJeIIxg6Q/s800/white_line.jpg" alt="white line" width="308" height="588" />
	<p class="wp-caption-text">White line from code above</p>
</div>
<p>The default color of the line is white, let&#8217;s change the color to blue using the setFillColor function. The setFillColor function also needs three parameters which range from 0 to 250 in this order:</p>
<ul>
<li>amount of red</li>
<li>amount of green</li>
<li>and amount of blue</li>
</ul>
<pre>--nameofline:setColor(Red, Green, Blue)
line_variable_name:setColor(0, 0, 250)</pre>
<p>The full code for the colored line is</p>
<pre>local line_variable_name = display.newLine(170, 400, 200, 300)
line_variable_name:setColor(0, 0, 250)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh4.googleusercontent.com/-QkUN8ygAIn4/TtWRsTrJBVI/AAAAAAAAAEg/AVFLmNj-83w/s800/blue_line.jpg" alt="blue line " width="308" height="588" />
	<p class="wp-caption-text">Blue line from code above</p>
</div>
<p>We can also change the width of the line with this function:</p>
<pre>--nameofline.width = number
line_variable_name.width = 10</pre>
<p>The full code for the colored line with a different width is</p>
<pre>local line_variable_name = display.newLine(170, 400, 200, 300)
line_variable_name:setColor(0, 0, 250)
line_variable_name.width = 10</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh3.googleusercontent.com/-azAApORj8uI/TtWRs4KaWyI/AAAAAAAAAEs/21reTkoKsvI/s800/blue_line_thick.jpg" alt="thick blue line" width="308" height="588" />
	<p class="wp-caption-text">Thick blue line from the code above</p>
</div>
<p>You can also append another segment to the line we just created by adding at least one x and y coordinate like in the following function</p>
<pre>--nameofline:append(x,y[x2,y2,x3,y3,xn,yn])
line_variable_name:append(160,240)</pre>
<p>The full code for our line with an additional segment is:</p>
<pre>local line_variable_name = display.newLine(170, 400, 200, 300)
line_variable_name:setColor(0, 0, 250)
line_variable_name.width = 10
line_variable_name:append(160, 240)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh3.googleusercontent.com/-MeC989N8F_g/TtWWczmmVhI/AAAAAAAAAFc/FjlAQbJ3JIo/s800/blue_line_one_segment.jpg" alt="two blue lines attached" width="308" height="588" />
	<p class="wp-caption-text">Blue line with one segment attached</p>
</div>
<p>We can also more than one segment to the original line.</p>
<pre>local line_variable_name = display.newLine(170, 400, 200, 300)
line_variable_name:setColor(0, 0, 250)
line_variable_name.width = 10
line_variable_name:append(160, 240, 300, 45, 91,480, 10, 450, 160, 0)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh6.googleusercontent.com/-aPDfGnzz9Eg/TtWRsDPUdEI/AAAAAAAAAEc/smsC7ju68XQ/s800/blue_line_thick_several_lines_connected.jpg" alt="Blue Line With Segments Attached" width="308" height="588" />
	<p class="wp-caption-text">Blue line with segments attached from the code above</p>
</div>
<p>You can also create more than one line at a time by adding different variable names like in our following example:</p>
<pre>local blue_line= display.newLine(170, 400, 200, 300)
blue_line:setColor(0, 0, 250)
blue_line.width = 10
blue_line:append(160, 240, 300, 45, 91,480, 10, 450, 160, 0)

local red_line= display.newLine(170, 400, 200, 300)
red_line:setColor(250, 0, 0)
red_line.width = 5
red_line:append(120, -43, 260, 5, 51, 440, -30, 450, -150, 0, 320, 480)

local green_line= display.newLine(170, 400, 200, 300)
green_line:setColor(0, 250, 0)
green_line.width = 15
green_line:append(0, 0, -300, 45, -10, -450, -160, 0, 10, 56, 79, -20, 90, 78)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh3.googleusercontent.com/-3ztfsMT-XnI/TtWZh-0eW_I/AAAAAAAAAGU/Dq_WAiwivXg/s800/different_blue_line_one_segment.jpg" alt="Different Line Segments" width="308" height="588" />
	<p class="wp-caption-text">Different line segments from the code above</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://webtutsdepot.com/2011/11/29/corona-sdk-tutorial-how-to-work-with-lines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Corona SDK Tutorial: How to Work With Rectangles</title>
		<link>http://webtutsdepot.com/2011/11/27/corona-sdk-tutorial-rectangle-objects/</link>
		<comments>http://webtutsdepot.com/2011/11/27/corona-sdk-tutorial-rectangle-objects/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 23:17:36 +0000</pubDate>
		<dc:creator>Carlos</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://webhole.net/?p=2240</guid>
		<description><![CDATA[In this tutorial we will teach you to work with rectangles in the Corona SDK.]]></description>
				<content:encoded><![CDATA[<p></p><p>When creating a rectangle in Corona SDK we must use the function newRect of the display object. This function takes four parameters (integers) in this order:</p>
<ul>
<li>left corner (x-coordinate)</li>
<li>top (left) corner(y-coordinate)</li>
<li>width</li>
<li>height</li>
</ul>
<p>&nbsp;</p>
<h3>config.lua</h3>
<p>First let&#8217;s make a config file to set the screen size.</p>
<pre class="prettyprint lang-lua">application =
{
     content =
     {
        width = 320,
        height = 480,
        scale = "zoomEven"
      }
}</pre>
<h3>main.lua</h3>
<p>Now lets work on the main.lua file. We can store the rectangle in a variable and use that variable later to change other properties of that rectangle like the fill color, the stroke color and the width of the stroke.</p>
<p>Let&#8217;s make a rectangle called &#8220;rectangle_variable_name&#8221; with the top left corner at (100,200), a width of 150, and a height of 100.</p>
<pre class="prettyprint">--local nameofrectangle = display.newRect(left-x-coordinate,top-y-coordinate,width,height)
local rectangle_variable_name = display.newRect(100,200,150,100)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh4.googleusercontent.com/-2ilhJzhtVYE/TtKse3AmwbI/AAAAAAAAACc/NCqwxZSEif0/s800/white_rectangle.jpg" alt="White Rectangle on Mobile application" width="308" height="588" />
	<p class="wp-caption-text">White rectangle from the code above</p>
</div>
<p>The default color of the rectangle is white, let&#8217;s change the color to green using the setFillColor function. The setFillColor function also needs three parameters which range from 0 to 250 in this order:</p>
<ul>
<li>amount of red</li>
<li>amount of green</li>
<li>and amount of blue</li>
</ul>
<pre class="prettyprint">--nameofrectangle:setFillColor(Red, Green, Blue)
rectangle_variable_name:setFillColor(0,250,0)</pre>
<p>The full code for the rectangle is</p>
<pre class="prettyprint">local rectangle_variable_name = display.newRect(100,200,150,100)
rectangle_variable_name:setFillColor(0,250,0)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh4.googleusercontent.com/-jFD7t5Tq8N4/TtKxDx_ms2I/AAAAAAAAAC0/S0TZ6gi9b8c/s800/green_rectangle.jpg" alt="Green Rectangle for Mobile Application" width="308" height="588" />
	<p class="wp-caption-text">Green rectangle from the code above</p>
</div>
<p>We can also add a stroke, and color to that stroke to the rectangle we just created with these two fucntions</p>
<pre class="prettyprint">--nameofrectangle.strokeWidth = any_interger
rectangle_variable_name.strokeWidth = 5
--nameofrectangle:setStrokeColor(Red,Green,Blue)
rectangle_variable_name:setStrokeColor(180,0,200)</pre>
<p>The full code for the rectangle is</p>
<pre class="prettyprint">local rectangle_variable_name = display.newRect(100,200,150,100)
rectangle_variable_name:setFillColor(0,250,0)
rectangle_variable_name.strokeWidth = 5
rectangle_variable_name:setStrokeColor(180,0,200)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh6.googleusercontent.com/-5EMPVRzLjMw/TtK1DxKMF5I/AAAAAAAAADM/Sc6vEZVKdZY/s800/green_rectangle_with_purple_stroke.jpg" alt="Green Rectangle with Stroke for Application" width="308" height="588" />
	<p class="wp-caption-text">Green rectangle with purple stroke</p>
</div>
<p>You can also create a rounded rectangle by using the function newRoundedRect of the display object. This one, unlike the other one will have one extra parameter.</p>
<ul>
<li>left corner (x-coordinate)</li>
<li>top (left) corner(y-coordinate)</li>
<li>width</li>
<li>height</li>
<li>corner radius **new**</li>
</ul>
<p>The code for this new rounded rectangle will be </p>
<pre class="prettyprint">--local nameofRoundedRectangle = display.newRoundedRect(left-x-coordinate,top-y-coordinate,width,height, radiusOfCorners)
local rounded_rectangle_variable_name = display.newRoundedRect(100,200,150,100,12)
rounded_rectangle_variable_name:setFillColor(0,250,0)
rounded_rectangle_variable_name.strokeWidth = 5
rounded_rectangle_variable_name:setStrokeColor(180,0,200)
</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Green Rounded Rectangle " src="https://lh6.googleusercontent.com/-3_U1qdMHS7c/TtK5uFRnYjI/AAAAAAAAADk/lagZjVVjYHk/s800/green_rounded_rectangle_with_purple_stroke.jpg" width="308" height="588" />
	<p class="wp-caption-text">Green rectangle with round corners</p>
</div>
<p>You can also create more than one rectangle at a time by adding different variable names like in our following example:</p>
<pre class="prettyprint">
local rounded_rectangle_one = display.newRoundedRect(100,150,150,100,12)
rounded_rectangle_one:setFillColor(0,250,0)
rounded_rectangle_one.strokeWidth = 5
rounded_rectangle_one:setStrokeColor(180,0,200)

local rectangle_one = display.newRect(0,0,160,400,3)
rectangle_one:setFillColor(50,250,100)
rectangle_one.strokeWidth = 1
rectangle_one:setStrokeColor(100,50,250)

local rectangle_three = display.newRect(0,20,300,100,12)
rectangle_three:setFillColor(250,0,0)
rectangle_three.strokeWidth = 5
rectangle_three:setStrokeColor(0,0,200)

local rounded_rectangle_two = display.newRoundedRect(50,100,80,70,25)
rounded_rectangle_two:setFillColor(180,180,0)
rounded_rectangle_two.strokeWidth = 10
rounded_rectangle_two:setStrokeColor(90,150,250)

local rectangle_two = display.newRect(80,300,150,100,12)
rectangle_two:setFillColor(50,0,0)
rectangle_two.strokeWidth = 5
rectangle_two:setStrokeColor(180,0,200)
</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Group of Rectangles" src="https://lh4.googleusercontent.com/-4zpLTKO0mMM/TtK_v2om3xI/AAAAAAAAAD8/uCrwGJ4nmrk/s800/grouped_rectangles.jpg" width="308" height="588" />
	<p class="wp-caption-text">Group of Rectangles</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://webtutsdepot.com/2011/11/27/corona-sdk-tutorial-rectangle-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Corona SDK Tutorial: Circle Objects</title>
		<link>http://webtutsdepot.com/2011/11/27/corona-sdk-tutorial-circle-object/</link>
		<comments>http://webtutsdepot.com/2011/11/27/corona-sdk-tutorial-circle-object/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 20:25:22 +0000</pubDate>
		<dc:creator>Carlos</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://webhole.net/?p=2219</guid>
		<description><![CDATA[The Corona SDK is great, we love it, but their API documentation is not so great, so we have taken it upon ourselves to show you in detail how to use this great library.]]></description>
				<content:encoded><![CDATA[<p></p><h3>Make a Circle</h3>
<p>To make a circle in Corona SDK we use the function newCircle of the display object. This function takes three parameters in this order.:</p>
<ul>
<li>the x coordinate for the center</li>
<li>the y coordinate for the center</li>
<li>the circle&#8217;s radius</li>
</ul>
<h3>config.lua</h3>
<p>First let&#8217;s make a config file to set the screen size.</p>
<pre class="prettyprint">application =
{
     content =
     {
        width = 320,
        height = 480,
        scale = "zoomEven"
      }
}</pre>
<h3>main.lua</h3>
<p>Now lets work on the main.lua file. We can store the circle in a variable and use that variable later to change other properties of that circle like color for example.</p>
<p>Let&#8217;s make a circle called &#8220;circle_variable_name&#8221; with the center at (160,240) and a radius of 50.</p>
<pre lang="lua">--local nameofcircle = display.newCircle( x-cordinate, y-cordinate, radius )
local circle_variable_name = display.newCircle(160,240,50)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh6.googleusercontent.com/-P1Bhwy4pzGE/TtKMhP-HpKI/AAAAAAAAABc/9Z0I-er9FfM/s800/White_Cirle_in_Center.jpg" alt="White circle on mobile application" width="308" height="588" />
	<p class="wp-caption-text">The result from the code above</p>
</div>
<p>The default color of the circle is white, let&#8217;s change the color to red using the setFillColor function. The setFillColor function also needs three parameters which range from 0 to 250 in this order:</p>
<ul>
<li>amount of red</li>
<li>amount of green</li>
<li>and amount of blue</li>
</ul>
<pre lang="lua">--nameofcircle:setFillColor(Red,Green,Blue)
circle_variable_name:setFillColor(250, 0, 0)</pre>
<p>The full code for the circle is this</p>
<pre lang="lua">local circle_variable_name = display.newCircle(160,240,50)
circle_variable_name:setFillColor(250, 0, 0)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh5.googleusercontent.com/-K4jOt6kqXTY/TtKMhm_cvlI/AAAAAAAAABk/1nmnX1L_C3w/s800/Red_Cirle_in_Center.jpg" alt="red circle in phone application" width="308" height="588" />
	<p class="wp-caption-text">the result from the code above</p>
</div>
<p>We can also add a stroke, and color to that stroke, to the circle just created with these two functions</p>
<pre lang="lua">--nameofcircle.strokeWidth = any_interger
circle_variable_name.strokeWidth = 3
--nameofcircle:setStrokeColor(Red,Green,Blue)
circle_variable_name:setStrokeColor(0,250,0)</pre>
<p>The full code for the circle is</p>
<pre lang="lua">
local circle_variable_name = display.newCircle(160,240,50)
circle_variable_name:setFillColor(250, 0, 0)
circle_variable_name.strokeWidth = 3
circle_variable_name:setStrokeColor(0,250,0)
</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img alt="Red Circle with Stroke" src="https://lh5.googleusercontent.com/-OqZhqr8PcVo/TtLDspDkDYI/AAAAAAAAAEU/5hHHF2Jp0d4/s800/Red_Cirle_with_green_stroke_in_Center.jpg" width="308" height="588" />
	<p class="wp-caption-text">Red circle with green stroke</p>
</div>
<p>Now to create more than one circle you simply create different variable names like in the following example</p>
<pre lang="lua">local circle = display.newCircle(160,240,50)
circle:setFillColor(100,190,0)

local circle1 = display.newCircle(100,150,30)
circle1:setFillColor(100,90,190)

local circle2 = display.newCircle(160,400,90)
circle2:setFillColor(250,30,190)</pre>
<div class="wp-caption aligncenter" style="width: 308px">
	<img src="https://lh5.googleusercontent.com/-Ij_ateHfn3o/TtKTI83HGRI/AAAAAAAAACE/9VOk-g_n5PM/s800/colored_circles.jpg" alt="Different colored circles on application" width="308" height="588" />
	<p class="wp-caption-text">Different colored circles</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://webtutsdepot.com/2011/11/27/corona-sdk-tutorial-circle-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
