Category Archives: Corona SDK

How to find your Google Plus ID

By | September 27, 2012

This is so simple 1. Go to your Google + account (https://plus.google.com/). 2. Click on the Profile icon on the Left. 3. If you look at the URL in the address bar, it should look something like this: https://plus.google.com/104653270154306099169/posts 4. The long numerical string in the URL is your Google+ ID. Here is CoderzHeaven’s from the URL above:… Read More »

How to Play Audio using Corona SDK ?

By | April 28, 2012

Hi, For playing audio – background music or sound effects – using Corona SDK, do the following, 1. Load the audio stream (background music or sound effects) [c] backgroundMusic = audio.loadStream("bgm.mp3") [/c] 2. Play the audio [c]backgroundMusicChannel = audio.play( backgroundMusic, { channel=1, loops=-1, fadein=5000 } ) [/c] It will play the background music on channel 1, loop infinitely,… Read More »

How to enable retina Mode in Corona SDK? or How to work with images in retina Mode in Corona?

By | April 26, 2012

To enable retina mode in your application you have to first find the config.lua file in your project folder. Then edit this file to include the contents like this. [java] application = { content = { width = 320, height = 480, scale = "letterbox", imageSuffix = { ["-x15"] = 1.5, — A good scale for Droid, Nexus… Read More »

How to get the elapsed time after app launch in Corona ?

By | February 18, 2012

In order to get the elapsed time after the application launch in Corona, use the following lines of code, [java]function elapsedTimeCalc( event ) print ("Time elapsed since app launch—"..event.time/1000 ) end Runtime:addEventListener("enterFrame", elapsedTimeCalc)[/java] Thus we will get the elapsed time after the app launch in milliseconds. 🙂

How to download an image in corona SDK?

By | January 26, 2012

Downloading an image in corona is really easy. Check out the example. [java] module(…, package.seeall) _W = display.contentWidth; _H = display.contentHeight; function new() local grp = display.newGroup(); local myImage; local function networkListener( event ) if ( event.isError ) then print ( "Network error – download failed" ) else myImage = display.newImage( "helloCopy.png", system.TemporaryDirectory, 60, 40 ) myImage.alpha =… Read More »

Gradient Text in Corona

By | January 24, 2012

To create gradient text in corona, you have to download ‘Corona daily build 612’ which has functions like setFillColor() etc. You create a new gradient object by calling graphics.newGradient(). You can pass (and reuse) the object in calls to text:setTextColor() and rect:setFillColor(). Here is an example. [java] local myText = display.newText( "Hello, World!", 0, 0, native.systemFont, 40 )… Read More »

Problem with touch in Corona on multiple views solved.

By | January 19, 2012

Hello everyone.. There has been a problem with corona that when you place one view over the other and when you touch the object in front of the other, touch will be migrated to the object below it. To prevent this there is a mechanism in corona. Here is how we solve this in corona. [java] display.getCurrentStage():setFocus( your_touched_obj)… Read More »

Most Common and most important String functions in Corona.

By | December 12, 2011

Here are some of the string functions that are most commonly used in Corona SDK. In this example you can find all the common string functions with a wroking example for each. This example contains functions to 1. Check the first character in a string 2. Check the last character in a string. 3. Changing the first character… Read More »

Different ways to trim a string in Corona SDK.

By | December 11, 2011

Here are the different ways to trim a string in Corona SDK. [java] — CoderzHeaven String Trimming examples in Corona. — Here you can see different methods for trimming a string in corona. function trim1(s) return (s:gsub("^%s*(.-)%s*$", "%1")) end function trim2(s) return s:match "^%s*(.-)%s*$" end function trim3(s) return s:gsub("^%s+", ""):gsub("%s+$", "") end function trim4(s) return s:match"^%s*(.*)":match"(.-)%s*$" end function… Read More »

Getting started with Corona

By | November 27, 2011

In the previous post I told you about corona SDK and Today I will show you how to get started with Corona SDK. 1. First Go to http://www.anscamobile.com/corona/ and download the SDK for trial. 2. If you are a MAC user then download the dmg or if you are windows user then download the exe installer. 3. Open… Read More »

Building games for android and iPhone

By | November 27, 2011

Today I will talk about building games for android and iPhone. There are a lot of SDK’s available for building games over the internet and I am here to talk about the CORONA SDK. Corona SDK is a software development kit created by Walter Luh, co-founder of Ansca Mobile. It allows software programmers to build mobile applications for… Read More »

Destroying Box2D Physics Bodies in Corona SDK

By | August 28, 2011

Hi, For destroying physics bodies in Corona SDK, use any of the following methods. [c] urBody:removeSelf() [/c] OR [c]urBody.parent:remove( urBody )[/c] Note : While Box2D objects will be safely retained until the end of the current world step, their Lua references will be deleted immediately. Therefore, be careful not to accidentally delete the same Lua object more than… Read More »

How to get touch location in Corona ?

By | August 21, 2011

Hi, For getting touch location in Corona, use the following code, [c] –Your touch event listener local function myTouchListener( event ) if event.phase == "began" then –Touch coordinates can be accessed by event.x/event.y properties of touch event print( "Touched!" ) print ("Touch X = #"..event.x) print ("Touch Y = #"..event.y) end end –Adding an event listener for touch… Read More »

How to get touch 'began', 'moved' & 'ended' in Corona ?

By | August 21, 2011

Hi, For getting touch ‘began’, ‘moved’ & ‘ended’ in Corona, use the following code. [java] –Your touch event listener local function myTouchListener( event ) if event.phase == "began" then print( "Touched!" ) elseif event.phase == "moved" then print( "Touches Moved!" ) elseif event.phase == "ended" then print( "Touches Ended!" ) end end –Adding an event listener for touch… Read More »

How to get touch ‘began’, ‘moved’ & ‘ended’ in Corona ?

By | August 21, 2011

Hi, For getting touch ‘began’, ‘moved’ & ‘ended’ in Corona, use the following code. [java] –Your touch event listener local function myTouchListener( event ) if event.phase == "began" then print( "Touched!" ) elseif event.phase == "moved" then print( "Touches Moved!" ) elseif event.phase == "ended" then print( "Touches Ended!" ) end end –Adding an event listener for touch… Read More »

How to get touch ‘began’, ‘moved’ & ‘ended’ in Corona ?

By | August 21, 2011

Hi, For getting touch ‘began’, ‘moved’ & ‘ended’ in Corona, use the following code. [java] –Your touch event listener local function myTouchListener( event ) if event.phase == "began" then print( "Touched!" ) elseif event.phase == "moved" then print( "Touches Moved!" ) elseif event.phase == "ended" then print( "Touches Ended!" ) end end –Adding an event listener for touch… Read More »

How to add label/text to image in Corona ?

By | August 21, 2011

Hi, For adding a label/text to an image in Corona, using Lua, use the following code, [java] local urGroup = display.newGroup() local urImage = display.newImageRect(‘sample.png’,70,70) urImage.x = 150 urImage.y = 250 local urText = display.newText( "SampleText", 0, 0, "Helvetica", 22 ) urText:setTextColor( 0, 0, 0, 255 ) — insert items into group, in the order you want them… Read More »