Share Your Code

Latest Additions


The latest additions of sample code and code libraries shared by developers for Corona SDK.

2 votes
Grid Manipulation Sample Code

This code allows you to move your player by touching the screen. The grid will then manipulate according to the players position. You can change the radius of the manipulated area, and change the line width. We are having problems with lag if there are multiply objects on the grid. If anyone can help solve the issue, we will update our code accordingly. Hope this helps! More...

Posted by Ninja Pig Studios, Posted on 6 Feb 2012, Last updated 7 Feb 2012 | 6 comments

0 votes
Continuous Scrolling Background

This is some code that was given to me for a continuous scrolling background that works pretty good. Just change the image filenames and set the speed in the code and it ready to go. Go to my website and tweet to get the download link for free. http://j-strahan.com/main/?category_name=free Enjoy this free code and others on my site. Thanks. More...

Posted by jstrahan, Posted on 5 Feb 2012, Last updated 5 Feb 2012 | 5 comments

2 votes
Particle Candy Effects Creator

This is a simple helper project to ease the creation of Particle Candy effects. I've been looking for a decent GUI to help me invent particle candy effects and couldn't find anything working, so I decided to go ahead and create my own GUI. For now it allows to adjust only Particle Type properties [and without fancy FX or fields or anything like that], but if you would like to get more, please let me know. More...

Posted by krystian6, Posted on 5 Feb 2012, Last updated 6 Feb 2012 | 5 comments

0 votes
Accurate tempo/BPM-based timing in your animations and music apps

Accurate tempo/BPM-based timing in your animations and general beat-sequenced stuff. I am using this logic in a spiffy metronome that I am porting over to iOS using Corona. I've used this rock-solid tempo pulse logic in my music apps for various platforms since 1998 and it has never done me wrong. More...

Posted by Gary Duke, Posted on 2 Feb 2012, Last updated 2 Feb 2012 | 0 comments

0 votes
Much Improved 'dump' function and XML simplify

UPDATE: This post now has a lot more functionality, described just before the code... Original blog post: http://blog.anscamobile.com/2011/07/how-to-use-xml-files-in-corona/ Original shared code: https://developer.anscamobile.com/code/xml-table-parser This code is an update/huge improvement to my original post, above. The dump function traverses a table's contained tree and prints all of it's content to the console... More...

Posted by horacebury, Posted on 2 Feb 2012, Last updated 3 Feb 2012 | 0 comments

0 votes
UTF-8 Encode and Decode

If you have problem using unicode from different network request (like the Facebook graph) you might find the UTF8 Encode function useful. If you need to decode there is a function for that to. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 --- -- Converts all UTF-8 character sets to unicode/ASCII characters -- to generate ISO-8859-1 email bodies etc. --@param utf8 UTF-8 encoded string --@return a ASCII/ISO-8859-1 8-bit conform... More...

Posted by Johantd04, Posted on 1 Feb 2012, Last updated 1 Feb 2012 | 0 comments

0 votes
Easy Finger Drawing with Undo Functionality

For an app I am soon to release, I needed to allow the user to draw a series of squiggily lines with his or her finger, and to be able to reference or remove specific lines/strokes. The closest bit of code I could find online was actually provided by Carlos (https://developer.anscamobile.com/forum/2011/05/02/need-some-help), but I found that his solution of appending new points onto a single line got laggy the... More...

Posted by jasonschroeder, Posted on 30 Jan 2012, Last updated 30 Jan 2012 | 4 comments

2 votes
TerraDestructa

Welcome to TerraDestructa TerraDestructa is a grid based destroyable terrain system for corona. This is the first release and should be considered an alpha. I do not think it's ready for a production app quite yet. That's your warning. However it's quite fun to play with and the included main.lua demos the main feature Just touch the squares to carve them away, the physics objects generate on the fly as you draw.... More...

Posted by brad.herman, Posted on 28 Jan 2012, Last updated 29 Jan 2012 | 1 comments

0 votes
cipr.ui

User interface utilities for Corona, part of the Cipr project. Installation Installation is done with cipr 1 cipr install git://github.com/six8/cipr.ui.git Usage Some examples. See Getting started with Cipr for more examples. See source for full functionality. EffectChain More...

Posted by cixate, Posted on 28 Jan 2012, Last updated 28 Jan 2012 | 0 comments

0 votes
cipr.struct

Data structure utilities for Corona, part of the Cipr project. Includes: cipr.struct.grid.Grid - An efficient 2D grid cipr.struct.grid.GridView - Translates a Grid into display coordinates cipr.struct.Set - An unorderd set cipr.struct.Vector2D - 2D vector operations Installation Installation is done with cipr cipr install git://github.com/six8/cipr.struct.git Usage Some examples. See source for full functionality... More...

Posted by cixate, Posted on 28 Jan 2012, Last updated 28 Jan 2012 | 0 comments

0 votes
Cipr

Cipr (pronounced "sipper") is part package manager, part development framework for Corona SDK. Much like Python's pip, Cipr makes it easier to share packages and integrate them into Corona apps. The Goal for Cipr is that there's a generous amount of third-party, best-of-breed packages available for use in Corona apps. This will help new developers get started developing apps sooner and reduce the re-inventing of the... More...

Posted by cixate, Posted on 28 Jan 2012, Last updated 28 Jan 2012 | 0 comments

0 votes
Radio Like Buttons

I was originally making this for an odesk project, but now that I realized how long it will take to perfect it, I will just update it as I go for everyone to use. It is like a check box. Here is how to use it so far: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 local control = require("control")    newBox = control.newControl(      ... More...

Posted by Gigabook, Posted on 27 Jan 2012, Last updated 27 Jan 2012 | 0 comments

0 votes
Random generator engine cross-platform

Hello! We have created this function for use on the daily challenge of our game MathCatch, because the random number generation on Android is different than IOS. Use: 1 2 3 4 5 6 7 8 9 10 11 12 13 --declare the module: urandom=require ("urandom")   --Call the random seed with: urandom.RandomSeed( seed )   --seed = a number between 0 and 99999   --Obtain a random number with:... More...

Posted by josua, Posted on 27 Jan 2012, Last updated 27 Jan 2012 | 0 comments

1 vote
Get Sprite by Name in a Sprite Sheet

Are you upset with the order of you sprite sheets? I am :) It's easy, for me, to sort sprite by name, example : "ship_1,ship_2", and to get the index of the first frame. Use the Basic layout in Zwoptex, then choose to order by name/Ascending. Here is a short snippet to get a sprite picture index in a sprite sheet. pSheetData is the sprite sheet used by sprite.newSpriteSheetFromData. pName is the picture name,... More...

Posted by dmekersa, Posted on 27 Jan 2012, Last updated 31 Jan 2012 | 0 comments

1 vote
Ad Manager for Corona

version 1.1 is out! New Feature: ad rotation! By using this simple module, you can configure ad network parameters on the fly. You can switch ad networks without updating your apps, change all supported ad network variables, display your own ads with house ads functionality, and even rotate your own ad stream without a hassle. All you need is a simple ad configuration text file sitting on your web space. Example... More...

Posted by deniz, Posted on 25 Jan 2012, Last updated 4 Feb 2012 | 7 comments

0 votes
XML to table parser

Please see the updated version: http://developer.anscamobile.com/code/much-improved-dump-function-and-xml-simplify http://blog.anscamobile.com/2011/07/how-to-use-xml-files-in-corona/ In the blog post above Jon Beebe explains how to use XML in lua via a small library module. The one downside with this was that tables returned, while well structured, are not structured with the XML naming schema of the XML file. I... More...

Posted by horacebury, Posted on 25 Jan 2012, Last updated 2 Feb 2012 | 0 comments

0 votes
Running Clock

This code will create a variable running timer for your game/app. Please see below for what to set it up. Functions: clock.cancelTimers(): This will cancel or pause your timers clock.resumeTimers(): This will resume your timers from a clock.cancelTimer call First you have to require the clock by writing: 1 local clock = require("clock") Then to set up a clock you have to follow this: 1 2 3 4 5 6 7... More...

Posted by jeremyapplebaum12, Posted on 22 Jan 2012, Last updated 22 Jan 2012 | 0 comments

0 votes
play sounds in sequence

Hope this helps someone :-) syntax 1 cSoundPlayer:play(paFiles, poListener) plays a sequence of sounds and takes a tablelistener as a param tableListener must implement function onComplete() example 1 2 3 4 5 6 myObj = {} function myObj.onComplete() print ("hey you played all the sounds") end   cSoundPlayer:play({"snd1.mp3", "snd2.mp3"... More...

Posted by open768, Posted on 21 Jan 2012, Last updated 21 Jan 2012 | 2 comments

1 vote
Simple PDF Reader App

Use this little piece of code to display PDF file in your Corona Apps! I'm running Corona Version 2012.726 (2012.12.8). --------------------------------------------- TESTED ON --------------------------------------------- -Xcode iOS simulator -iPhone 4 and iPad 2 running iOS 5.0.1 --------------------------------------------- LIMITATION TO DISPLAYING PDF FILES USING THIS METHOD... More...

Posted by b00stup, Posted on 20 Jan 2012, Last updated 20 Jan 2012 | 1 comments

3 votes
Follow Object

I ported this nice AS2 follow-object script by Philip Radvan see the original post here http://www.freeactionscript.com/2009/04/enemy-behavior-run-away-follow-player/ fin.lua 1 2 3 4 5 6 7 8 9 10 11 local fin = {}   fin.distanceBetween = function ( pos1, pos2 )          local sqrt = math.sqrt         if not pos1 or not pos2 then    ... More...

Posted by canupa.com, Posted on 18 Jan 2012, Last updated 19 Jan 2012 | 8 comments

4 votes
Calculating actual boundaries of your application and device screen size

When you develop some Corona application, you most probably use some content scaling option specified in your config.lua file. Content scaling is described perfectly in this blog post: http://blog.anscamobile.com/2010/11/content-scaling-made-easy/ More...

Posted by mmagrilov, Posted on 13 Jan 2012, Last updated 16 Jan 2012 | 6 comments

1 vote
Point to Point Dragable Travel Objects

I decided to create a reusable function to easily declare any number of objects to travel from point A to point B at designated speed. Was planning on using it in future games... you know, creating cool features before I need them. The idea was later built upon to allow dragging around of the starting and ending points with the objects spacing out in proportion accordingly. Have fun tweaking the code :) main.lua: 1... More...

Posted by TimeSpaceMagic, Posted on 12 Jan 2012, Last updated 13 Jan 2012 | 2 comments

0 votes
Basic drawing code

This is a very simply point drawing piece of code. Click on the simulator to create dots. Each new dot is joined to the last by a line. The length of the line is displayed next to it. The dots can be dragged and the first dot is green. Tap a dot to remove it. main.lua: 1 2 3 4 5 6 7 8 9 10 11 12 local stage = display.getCurrentStage()   local dots, lines = display.newGroup(), display.newGroup... More...

Posted by horacebury, Posted on 12 Jan 2012, Last updated 13 Jan 2012 | 4 comments

0 votes
Calculating area of an object

I have wanted to calculate the mass of an object for use in my previously submitted sample code (trajectory plotting.) The following code does that - calculates the area of an object, where it's points are clockwise in order and do not overlap. The limitation of 8 points maximum is not present. Using files produced from PhysicsEditor (that of a table of tables to represent more than 8 points) is left as an exercise... More...

Posted by horacebury, Posted on 7 Jan 2012, Last updated 7 Jan 2012 | 0 comments

1 vote
RSS Parser Take Two

I've replaced the old RSS parser with this one..... Please use this one instead. This project includes a very basic RSS parser which requires the use of Jonathan Beebee's XML parser (included). It should process any well formed, valid RSS 2.0 feed. I still need to update the atom.lua parser for ATOM 1.0 feeds and it will be added here when it's ready. Please note, you will need daily build 721 if you want to use... More...

Posted by robmiracle, Posted on 6 Jan 2012, Last updated 6 Jan 2012 | 25 comments

0 votes
Load or Save Defaults / Preferences

This is some sample code to show one way in which you application / game can preserve state between sessions. There are many ways to do this, here is mine. Use it, abuse it, add to it, whatever you like. Happy to hear from you if you have extras to contribute, but I dont need to know if you use another method. ;) (I may move these functions out into a lobal.lua file at some point) To make use of this system, there... More...

Posted by jeff472, Posted on 5 Jan 2012, Last updated 7 Jan 2012 | 2 comments

1 vote
TileBG - Tile and manage a image on the display background

I'm still on my demo time, trying to get the hang of this Corona thing... loving every minute! I was trying to do what I thought would be simple...tile an image on the background of the display. And thats what this does: It detects your display content height and attempts to calculate the minimum number of tiles needed (based on the size of the provided background tile.) This is simple to use: 1) Include the... More...

Posted by ethanpil, Posted on 2 Jan 2012, Last updated 2 Jan 2012 | 0 comments

0 votes
Trajectory plotting

[EDIT: I have updated the code to provide a better user interface and make the calculated trajectory path longer if necessary] I've been wanting to pre-calculate the curve of an object fired Angry Birds style for some time. I am terrible with maths, trigonometry etc and this has been a real challenge. I also wanted to make this code available. I'm not going to explain the code - it is fairly self explanatory. In... More...

Posted by horacebury, Posted on 30 Dec 2011, Last updated 10 Jan 2012 | 6 comments

2 votes
Simple XML Parser

Story I've used XML Parser created by Jonathan Beebe ( http://blog.anscamobile.com/2011/07/how-to-use-xml-files-in-corona/ ) to read small and simple XML files. However for one of my projects I do have a large XMLs to parse which are generated automatically for me. As you know, automatically may mean - random. Using a list of nodes and looping through it was out of the question. This is why I've created this little... More...

Posted by krystian6, Posted on 27 Dec 2011, Last updated 27 Dec 2011 | 5 comments

0 votes
Easy custom TextBoxes with custom keyboard

Hi! Native textboxes have a lot of little troubles in game apps with fonts, scene changes, etc. I have coded this custom textboxes with is own custom keyboard for easy text entry in games that not need a complete keyboard. The code needs TextCandy library for work, but you can easily modify for not need it. Scroll text inside the text box or limit text length is not implemented yet! 1 TextCandy = require("... More...

Posted by josua, Posted on 26 Dec 2011, Last updated 26 Dec 2011 | 0 comments

4 votes
Text Wrapper Class

As I needed some text features for my actual project, I wrote a class to wrap some text. Unfortunately I saw only now that there is still one form tom.knox7. As there are a bit more features in my class, i post it anyway for someone who need this features maybe. --------------------------------------------------------------- There are two main usages of the module: 1. You can wrap any text to a desired width, the... More...

Posted by sunmils, Posted on 22 Dec 2011, Last updated 4 Feb 2012 | 41 comments

0 votes
Strip HTML Tags from Text

There is no genius here on my part, I just started with Corona a few days ago, however, I found a lua snippet that removes HTML tags from code, leaving just the plain text, and its working great for me. The original source for the code: http://board.ptokax.ch/index.php?topic=7165.0 I made a slight change in the first few lines to make it work with the text that is passed in vs from a file. It has worked well for me... More...

Posted by ethanpil, Posted on 20 Dec 2011, Last updated 20 Dec 2011 | 2 comments

1 vote
Virtual Reality Experiment

An experiment to show a virtual reality still image using Corona SDK. In theory, this could be an animation, too... feel free! The app senses the physical attitude of the device using the gyroscope. As you turn the device, the image moves, as though you were turning your head. You can spin in a chair and see the world around you. It seems to freeze in the vertical some times. Quit the app, shut it down, and it... More...

Posted by mimetic, Posted on 17 Dec 2011, Last updated 18 Dec 2011 | 5 comments

1 vote
oop - no metas, no module()

Introduction I've build a Class - with actually just one function - for easy and very basic OOP in Lua. After some tryings I've decided to go without metatables and without module(...). This is my own approach and of course ain't the best out there, but as far as I've tested it, it does its job very well for me, so may it do for you too. My first approach was using metas, as everywhere suggested. And this... More...

Posted by jack0088, Posted on 16 Dec 2011, Last updated 19 Dec 2011 | 1 comments

1 vote
Dynamic Resolution Retina Text Class

Overview: Autoscaling retina text with a unified API, embossed option, automatic reference pointing and repositioning. ---- Hey guys, I'm sharing this simple text class because I've personally run into a lot of trouble getting text to scale and align perfectly in Corona over many screen sizes. I'd assume most of you are using some custom workarounds already! More...

Posted by Revaerie, Posted on 14 Dec 2011, Last updated 14 Dec 2011 | 1 comments

1 vote
Animated Number Ticker

I wrote this snippet as a proof of concept for a score/time keeper in a game I'm currently working on. The createTicker() function takes two parameters: a number, and the number of digits you want the display to be. It then generates a 'card' for each digit, based on the width and height of the number font + padding. More...

Posted by bryan.vaccaro, Posted on 13 Dec 2011, Last updated 13 Dec 2011 | 2 comments

4 votes
Calculating Trajectory

This code calculates every point (to the granularity you want) of an object travelling along a trajectory, starting with a given angle and velocity. I wanted to provide some very simply functions developers can call and have the most simple demonstration code - because that's all I can deal with. I have to say that I did not work this stuff out myself, but just went looking for a really good tutorial, which I found... More...

Posted by horacebury, Posted on 5 Dec 2011, Last updated 5 Dec 2011 | 6 comments

3 votes
classes.lua - A simple Class implementation in Lua for Object-Oriented Programming

What? classes provides a simple solution to Object-Oriented Programming in Lua. It has the basic OOP features one might expect, such as inheritance, and covers up dealing with metatables and the like. Why? classes was developed because when I started working with Corona, I had only a basic knowledge of Lua. Working on big projects, in any language, can usually benefit from some OOP functionality. There are a few... More...

Posted by paul.andrewharr..., Posted on 4 Dec 2011, Last updated 5 Dec 2011 | 2 comments

1 vote
Multi-Point Pinch Zoom Rotate

Previous example: https://developer.anscamobile.com/code/pinch-zoom-rotate [EDIT: If you take a closer look at the main.lua, I had recently added code to pinch-zoom a display group, instead of an image. This means that the group can have a lower quality image at smaller scales and a larger image (lazily loaded) at larger scales. While this could be handled in the pinch library, I thought it better - for now - to... More...

Posted by horacebury, Posted on 2 Dec 2011, Last updated 15 Jan 2012 | 9 comments

0 votes
Display.Save Image Not post on Facebook wall

Display.save image not post on faceBook Wall local function networkListener( event ) if ( event.isError ) then print( "Network error!") else print ( "RESPONSE: " .. event.response ) end end postData = "color=red&size=small" joinGroup:insert(boardGroup) joinGroup:insert(mainGroup); local baseDir = system.DocumentsDirectory; display.save( joinGroup, "screencapture.jpg", baseDir... More...

Posted by dvbaraiya, Posted on 1 Dec 2011, Last updated 1 Dec 2011 | 1 comments

2 votes
Pinch Zoom Rotate

For some time I have been wanting to write a usable pinch zoom with rotate algorithm. Finally, I think I have a serviceable piece. So, first off, usage: Give the code an image (I'm using yoda.jpg) Run the code Tap once to create the first or two touch points Tap somewhere else to create the second of the two touch points Drag one of the two touch points around to scale, rotate and move the image Tap once anywhere to... More...

Posted by horacebury, Posted on 27 Nov 2011, Last updated 28 Nov 2011 | 0 comments

1 vote
Pausable Transitions - A very simple method

Yeah I know there are a lot of transition managers.. Still never hurts to share code.. So here goes. USAGE : 1 2 3 transition.to(object,params} transition.pause(object)     transition.resume(object) I am not sure about the efficiency of this module. So if anyone has any modifications or if anyone finds any bug, please comment below. And I haven't tested this completely, but till... More...

Posted by Satheesh, Posted on 26 Nov 2011, Last updated 27 Nov 2011 | 5 comments

5 votes
Missile Command

A step-by-step tutorial showing how to create a Missile Command game using the Corona SDK. The resulting game is compatible across iOS and Android devices. The repository includes: assets: all of the graphics, audio, etc. required in the game; exercises: if you want to start with a particular exercise, then you can refer to the corresponding folder and start from there; MissileCommand: the finished game, if you... More...

Posted by Ludicrous Software, Posted on 24 Nov 2011, Last updated 24 Nov 2011 | 2 comments

1 vote
Corona Slot Machine

Corona Slot Machine is a simple example code that can be used to create a Slot Machine or Casino style app. The example features a fully functional slot machine that cycles through seven images on three slides to create a slot machine feel. This is just the skeleton of the code that can be changed to have a different look or extra features, or be used as is. More...

Posted by ertzel, Posted on 22 Nov 2011, Last updated 24 Nov 2011 | 3 comments

1 vote
RagDoll example

Code: https://files.me.com/horacebury/dzd1ev Swf Video: https://files.me.com/horacebury/cctx6z I've been wondering about the issue surrounding Ragdoll physics in Corona and had always wanted to produce a direct comparison to illustrate the differences various developers are seeing, myself included. Recently, I found some JavaScript ports of the Box2D Flash engine and thought that I would attempt a rag doll scenario... More...

Posted by horacebury, Posted on 22 Nov 2011, Last updated 22 Nov 2011 | 16 comments

5 votes
Virtual DPad/Joystick template

I've made a virtual dpad to test a tilt-based project and came out with something I think will be really useful for those out there wandering how to make a virtual controller for their apps. Its features are: - Visible only at finger touch. - Tracks angle and magnitude. - Draggable from its bounds. - Confined to screen limits. The download link and a video showing the thing in action can be found at our website:... More...

Posted by Alejandro Jimenez, Posted on 19 Nov 2011, Last updated 19 Nov 2011 | 9 comments

1 vote
Run Rabbit Run

Run Rabbit Run - simple scrolling platform game. Rabbit run and jump between platforms, catch lives and carrots. The goal of project is provide new Corona SDK developers with simple game template. Fill free to use any part of game as you wish. I will write more details about "how to" on my blog aabweber.com You can download game here. More...

Posted by aabweber, Posted on 17 Nov 2011, Last updated 17 Nov 2011 | 4 comments

0 votes
HSV to RGB

A little snippet to help you converting HSV Colors to RGB. Useful if you want to have a well saturated Color or to get variations of a color! Example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 display.setStatusBar(display.HiddenStatusBar)   local function hsvToRgb(h, s, v)         local r, g, b         local i         local f,... More...

Posted by xxxfanta, Posted on 15 Nov 2011, Last updated 15 Nov 2011 | 0 comments

3 votes
Corona Comics 2.0

The Corona Comics SDK 2.0 is based on the 1.0 version from November, 2010. In truth, this code is not as much an SDK as a demo of a fully functioning app using the code. It is a Lite version of Electric Eggplant’s iPad app, “Be Confident in Who You Are: A Middle School ConfidentialTM Graphic Novel” with all the functionality intact. It contains the opening animation and all of chapter 1, plus the Info page, and... More...

Posted by Gilbert, Posted on 11 Nov 2011, Last updated 11 Nov 2011 | 20 comments

0 votes
Move Camera

This is a very very very very simple module, just for those people who are just beginning, I remember when i was having struggles with moving the camera with objects outside of the screen. Go to sites.google.com/site/myplace2go2/corona-sdk and download the attachment camera.lua How to use: 1 2 3 4 5 6 7 8 9 10 --------------------- -- require camera --------------------- local camera = require("camera... More...

Posted by Gigabook, Posted on 10 Nov 2011, Last updated 10 Nov 2011 | 3 comments

0 votes
MtG Life Counter

Hey. Made a simple, 2-person MtG life counter. Using the ui.lua, and ZoomEven config. Inspiration: Button Counter Forum Post Button Events Template Feel free to comment/update. Would like to include dice roll and poison counter tally at some point. 1 2 3 4 5 6 7 local ui = require("ui")   --HALF BACKGROUND-- local Rect = display.newRect(0, 0, 340, 240) Rect:setFillColor( 64, 64... More...

Posted by jtreu, Posted on 8 Nov 2011, Last updated 8 Nov 2011 | 0 comments

0 votes
I18N Strings

Java-Like Locale String Resources (i18n) I found a few examples of locale string resource handling in Corona, but I wasn't satisfied. I thought Rosetta had a good thing going, but I couldn't use it as I wanted to. This class allows strings to be added in a genreal to more specific way. You set up the resources files from most general to most specific. The first one, strings.i18n, should always be present and... More...

Posted by bpappin, Posted on 29 Oct 2011, Last updated 29 Oct 2011 | 4 comments

5 votes
Director Slim - Stripped down Director Class

I've managed to strip it down to only 15 lines of code! That's right. Plus 6 lines for the header. Works faster, with lower overhead - hence higher performance. UPDATE 2011-11-05: Reduced to 15 lines. Fully working example added to GitHub. I didn't like director 1.3 when it came out, so I decided to stick with version 1.2a - the one with improved group cleaning function. I was fine with it thanks to Ricardo and... More...

Posted by Lerg, Posted on 29 Oct 2011, Last updated 4 Nov 2011 | 30 comments

0 votes
Jake Gundersen

An implementation of the recursive algorithm found on krazydad.com to create lightning/electricity bolts. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 local curDetail = 1   lines = display.newGroup()   function drawLightning(x1, y1, x2, y2, displace, r, g, b)         if displace < curDetail then                ... More...

Posted by fattjake8, Posted on 29 Oct 2011, Last updated 29 Oct 2011 | 2 comments

0 votes
Soft physics body

I thought soft bodies looked cool and thought of a way to make one myself. This is probably not a good way to do it. Crashes corona if the body starts spinning too wildly. This requires http://developer.anscamobile.com/code/make-outside-edge-walls-module if you can't be bothered to get that module, delete: "walls = require("walls") walls.make() " from the code. 1 2 3 4 5 6 7 8 9 10 11 display.setStatusBar(... More...

Posted by anddrewscott, Posted on 28 Oct 2011, Last updated 28 Oct 2011 | 0 comments

1 vote
Make outside edge walls module

This is hardly groundbreaking. It is a faster and easier way to make outside edges. I heard something about a corona update involving modules so this may be broken. meh. save as "walls.lua" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 module(..., package.seeall)   local W = _W --display.contentWidth local H = _H --display.contentHeight   function make()   wallGroup = display.newGroup()... More...

Posted by anddrewscott, Posted on 28 Oct 2011, Last updated 28 Oct 2011 | 1 comments

2 votes
Liquid Simulation For Corona SDK

Optimization of the code See the video at: http://www.youtube.com/watch?v=pPkBw9fIZGU Second test: http://www.youtube.com/watch?v=KMYCPq2w-8s Here is the code: 1 2 3 4 5 6 7 ------------------------------------------------------------------- -- --      Copyright 2011 Emilio Aguirre, All Rights Reserved. --  www.emilioaguirre.com -- -- Permission is hereby granted, free of charge, to any person... More...

Posted by eaguirre, Posted on 27 Oct 2011, Last updated 30 Oct 2011 | 11 comments

2 votes
graffitiPS Free -- A free particle system

Graffiti Particle System Free   Features: Small file size, less then 15kb Works with Director, SceneManager Create particles with unlimited use of the newCircle API Create text particles with limited functions ( native.systemFont only & max of 4 characters ) Move a distance from a point or converge to a point Scale, rotate, fade in/out, set color, set a max number or particles per group Activate a function at... More...

Posted by jstrahan, Posted on 24 Oct 2011, Last updated 24 Oct 2011 | 8 comments

0 votes
Example MessageBox code

A common feature in a lot of games and applications is the use of a MessageBox to display some text to the user and provide then with different buttons to signify what action they want to take. Something like a "Do you want to Exit?" with a Yes and No button. I have posted source for the cMessageBox.lua module along with sample tests showing the features of this code. The code depends on the ui.lua module (... More...

Posted by KenRogoway, Posted on 23 Oct 2011, Last updated 23 Oct 2011 | 9 comments

0 votes
Orientation Rotation in Web Popup

This code creates an app with a single, full screen native web overlay control. The main.html is loaded into it and JQuery is then used to repeatedly load a file indicating the device orientation. The orientation is detected within Corona and written to another HTML file. CSS is used to re-orient the web page within the web overlay control. Known issues: Demo does not adjust widths of HTML elements yet Demo does not... More...

Posted by horacebury, Posted on 23 Oct 2011, Last updated 23 Oct 2011 | 2 comments

1 vote
How To - Upload an Image to a server (multipart/form-data)

Generates multipart form-data suitable for use with Corona SDK's network.request(...) function. Updated 2011-10-29: Added some server side example code. Updated 2011-10-24: I refreshed the source to make sure I didn't copy it wrong (some people were having trouble getting it to work). Updated 2011-10-23: I've replaced the app specific code with a class I wrote to handle generating the POST body and headers. More...

Posted by bpappin, Posted on 22 Oct 2011, Last updated 5 Jan 2012 | 15 comments

1 vote
Simple Floating Keyboard (all Corona, no native)

Update 2011-10-27: - several bug fixes Download it from here: http://dl.dropbox.com/u/62099/sglkeyboard-v1.1.zip I'm working on a first app for Sixgreen Labs. We found it a real pain that the native inputs wouldn't work in the Simulator (although we understand why and empathize with the Corona team) I just wrote this up because I was getting consistant crashing in the Simulator from http://developer.anscamobile.com... More...

Posted by bpappin, Posted on 21 Oct 2011, Last updated 27 Oct 2011 | 1 comments

1 vote
Segmented Control Widget

Requires Corona Build 645 or higher! The segmented control widget has been removed from the upcoming widget version 0.2, so the source has been made publicly available here as a separate module. Here is the API documentation: More...

Posted by jonathanbeebe, Posted on 21 Oct 2011, Last updated 21 Oct 2011 | 3 comments

1 vote
js.lua

Features: 1. js.memCheck — checks memory usage and prints to the terminal window 2. js.memRepeat — checks memory usage and prints to the terminal window every so many seconds you set, also cancels the repeat 3. js.highscoreAdd — adds a name and score to a highscore table and sorts it highest to lowest can save as many... More...

Posted by jstrahan, Posted on 20 Oct 2011, Last updated 20 Oct 2011 | 7 comments

0 votes
Multiline text with width in pixels and justified on both sides

Hi I writes this code for put text justified on both sides. I'm newbie in Corona and it's possible the code is not optimized, but it works! Excuse for my english level also :( First, you need to add this function to util.lua because she's need the explode function included on it. 1 2 3 4 5 ---------------------FUNCIO PER TALLAR I JUSTIFICAR UN TEXT--------- function tallaJustifica(elText, laFont, laMida, elColor... More...

Posted by josua, Posted on 18 Oct 2011, Last updated 18 Oct 2011 | 0 comments

1 vote
Sequence.lua - Transition Execution order

Hello everybody! I am a bit new to Corona but i am working on a game template. Below you can find the class i wrote to handle sequential animations (function calls). It's really easy but i think it will be helpful for somebody here. My idea is to integrate it with TransitionManager somehow, but still havent stated with that, if somebody has any ideas about it i will be glad to here them. PS: I think methods like... More...

Posted by calledpaul, Posted on 17 Oct 2011, Last updated 17 Oct 2011 | 0 comments

1 vote
Swipe Direction

Here is a way to detect swipe direction: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 local beginX local beginY   local endX   local endY   local xDistance   local yDistance     function checkSwipeDirection()           xDistance =  math.abs(endX - beginX) -- math.abs will return the absolute, or non-negative... More...

Posted by mf, Posted on 15 Oct 2011, Last updated 15 Oct 2011 | 4 comments

0 votes
we will miss you steve jobs by dsrawat4u@gmail.com

This tutorial is build for a tribute to "Steve Jobs:The man behind apple" From me(Deepak Singh Rawat) using a better way to understand movieclip action with buttons!! For more information check my blog :- www.anscacorona.blogspot.com or My youtube channel :- www.youtube.com/user/iphonemaclover thank you Have fun with corona SDK File included:- main.lua mainmenu.lua loadmainmenu.lua More...

Posted by Deepak Singh Rawat, Posted on 13 Oct 2011, Last updated 5 Dec 2011 | 1 comments

4 votes
Load Progress Bar

This example shows you how to add a progress bar to your loading screen. The progress bar updates after each data chunk is loaded. You can change the bUseListener value in cSceneLoad.lua to specify if you want the bar updated every frame, or just when each data chunk has been loaded (preferred method). This example is licensed under the MIT license so you are free to modify it and use it however you like. More...

Posted by KenRogoway, Posted on 12 Oct 2011, Last updated 12 Oct 2011 | 42 comments

2 votes
Simple graphical timed score

Hi for this example you need a 25x29 transparent png for every number from 0 to 9, named n#.png. This example is for a 6 digits score. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 display.setStatusBar (display.HiddenStatusBar)   --Define variables local imatgesScore= {} local scoredigit={} local scoreResta=0 score=0   --Initialize scoredigits to Zero for m=0,5,1 do  ... More...

Posted by josua, Posted on 12 Oct 2011, Last updated 12 Oct 2011 | 1 comments

3 votes
Water Buoyancy Example

I am currently working on a game (my first in fact) which unexpectedly has led me down this long, but productive, detour of a road in trying to implement a buoyancy effect that makes physics objects float realistically when dropped into a body of liquid. More...

Posted by iNSERT.CODE, Posted on 10 Oct 2011, Last updated 10 Oct 2011 | 10 comments

2 votes
Add Community module to your app (FAQ, News, Forum etc)

While developing our latest app iKululu 2.0, we've been approached by the great guys at ngKit.com. They have built a great new product - a community module for app developers. If you ever wanted to communicate and engage your customer in a better, more convenient fashion - this is the way to go. To add the community module you will need to update the ID & secret key in the module file. Include the module and all... More...

Posted by shaharzrihen, Posted on 9 Oct 2011, Last updated 9 Oct 2011 | 2 comments

1 vote
Using splash/load screen on Android

When developing apps for both iOS and Android I've wanted a standard way to display a splash screen while the app is loading. I've written a small module that provides 2 options: Option 1) iOS has a nice built-in feature that displays an image (Default.png) while the app is loading. This option takes advantage of the iOS image files. Option 2) If you don't want/need a graphic (which might in itself might take a few... More...

Posted by ingemar, Posted on 2 Oct 2011, Last updated 6 Oct 2011 | 1 comments

0 votes
A different way of managing dynamic image resolution [and scaling font size]

// A note: after a comment by nicholasclayg I've changed my code so that now it doesn't use "package.seeall" (now deprecated) and therefore doesn't use global namespace // // Note 2: I've loaded my example code (for Windows) on GitHub; this version of DynResManager contains also some useful functions for determining actual screen size of your device and real values of visible x/y boundaries. Next time I'll explain... More...

Posted by mmagrilov, Posted on 1 Oct 2011, Last updated 7 Nov 2011 | 7 comments

1 vote
Orbital Rotation

Showing how to set up an orbital rotation for your corona sdk project. In this example the moon orbits the earth. Download Source: http://www.sims3tinkers.com/orbitalrotationcoronasdk.zip 1 2 3 4 5 6 7 8 9 10 11 12 -- -- Orbital Rotation - Moon around Earth -- Demonstrates one method for orbiting objects -- By Wintermuteai1 - http://www.sims3tinkers.com -- Version: 1.0 -- -- Sample code is MIT licensed, see http... More...

Posted by wintermuteai1, Posted on 30 Sep 2011, Last updated 30 Sep 2011 | 5 comments

1 vote
Pinch-zoom example

It's simple to use, just do something like: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 --hide the statusbar display.setStatusBar( display.HiddenStatusBar )   --include the mtouch library local mtouch = require( "mtouch" )   --create the zoom object - an image local image     = nil   local function OnZoomIn( event )  --grow our image  image.... More...

Posted by ldanadrian, Posted on 30 Sep 2011, Last updated 30 Sep 2011 | 1 comments

1 vote
Ghost vs Monsters - OOP

This is Ghost vs Monsters re-written in an object-oriented style of programming. It's intended as a example of how one might separate functionality within the application. Many thanks to everyone at Beebe Games and Ansca for making the code publicly available! More...

Posted by dmccuskey, Posted on 29 Sep 2011, Last updated 18 Oct 2011 | 3 comments

19 votes
Ice

Ice allows you save and load data when using the Corona ® SDK. It is very simple to use and allows you to create as many 'iceboxes' as you like. Great for storing local high scores, settings and other data. I hope to update my site here - http://grahamranson.co.uk/lib.php?id=6 - with proper usage instructions but until then you can get the majority of stuff done pretty easily. 1 2 3 4 5 6 7 require( "ice... More...

Posted by GrahamRanson, Posted on 29 Sep 2011, Last updated 13 Nov 2011 | 189 comments

1 vote
Simple menu system for Director Class

When prototyping a game using the Director Class (http://developer.anscamobile.com/code/director-class-10) it's useful to have a simple menu to test out different scenes. I quickly built this simple menu system to help quickly test scenes/levels. menu.lua 1 2 3 4 5 6 7 module(..., package.seeall)   local localGroup = display.newGroup()... More...

Posted by davidchiu, Posted on 28 Sep 2011, Last updated 28 Sep 2011 | 0 comments

0 votes
Throwback Football

Here's the code for "Throwback Football" that we did at the Corona Hackathon It's an example of what can be done with the Corona SDK in 8 hours and shows some key features like global variables, director usage, physics, timers, transitions, basic AI, etc. Read the blog here Enjoy, Croisened More...

Posted by croisened, Posted on 26 Sep 2011, Last updated 26 Sep 2011 | 0 comments

7 votes
Flickr Photo Browser

Awhile ago, I was approached to do a custom app for someone. The app itself is finished (not published yet) and in the process of creating it I thought it would be a good idea to publish the source for the dynamic image slider control I created. Well, not content with just publishing a simple control, I decided to create an entire demonstration app to see it in action. The Flickr Photo Browser is the result of this... More...

Posted by codepunk_schmidt, Posted on 20 Sep 2011, Last updated 20 Sep 2011 | 8 comments

0 votes
point-rectangle collision detection

the routine detects the collision between a rectangle (rotated at an arbitrary angle) and a point (x,y) 1 2 3 4 5 6 7 8 local function hitTest(rectangle,x,y)         --coordinates of the four vertices         local points={{-rectangle.width/2,-rectangle.height/2},{-rectangle.width/2,rectangle.height/2},{rectangle.width/2,rectangle.height/2... More...

Posted by tetu, Posted on 19 Sep 2011, Last updated 19 Sep 2011 | 2 comments

0 votes
Updating gravity

:D I found a way, I don't think it has been posted (if it is I look stupid :L ) This code will update the gravity on every enterFrame (should probably change that to a timer every second) to the variable grav. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 grav = 1 function gravi() print(grav) grav = 10 print(grav) end timer.performWithDelay(5000,gravi)        --]]... More...

Posted by anddrewscott, Posted on 19 Sep 2011, Last updated 19 Sep 2011 | 0 comments

1 vote
abc alphabet learner Tutorial using table View in ansca corona

This tutorial is build using list view of corona sample. For more information check my blog :- www.anscacorona.blogspot.com or My youtube channel :- www.youtube.com/user/iphonemaclover thank you Have fun with corona SDK --xxxxxxxxxxxxxxx main.lua file xxxxxxxxxxxx 1 2 3 4 5 6 7 8 9 10 --import the table view library local tableView = require("tableView")   --import the button events library... More...

Posted by Deepak Singh Rawat, Posted on 19 Sep 2011, Last updated 5 Dec 2011 | 19 comments

0 votes
making an object point at a touch event

It isn't a major thing, but I find it can be useful. I have not yet thought of a way to do it without physics. How I do it: The code will make an object called "arr" (I don't know why I called it that) which is attached to the player. The players rotation is found by finding the angle between the player and the arr object. This will run on its own: 1 2 3 4 5 6 7 8 9 10 11 physics = require( "physics... More...

Posted by anddrewscott, Posted on 17 Sep 2011, Last updated 17 Sep 2011 | 4 comments

0 votes
DMC Lib - Drag and Drop

dmc_dragdrop is a module which coordinates drag and drop operations in an application. It can be used to implement things like draggable shopping carts or even a vehicle configurator (e.g., engine, weapons, tires, etc). The module's functionality is based on that of the Adobe Flex Drag Manager, so if you've used that before, then the operation of dmc_dragdrop will be very familiar. Though the module is fully object-... More...

Posted by dmccuskey, Posted on 15 Sep 2011, Last updated 15 Sep 2011 | 5 comments

4 votes
Camera

Just a simple Camera module that might be of use to some people. I wrote this pretty quickly so some more testing will still need to be done, please comment on here if you find anything. Usage is very simple, just require the library, create a new Camera and then add some objects to it. You can then scale, rotate and move it as well as use a transitionTo function on it. Parallax layers are also supported and are... More...

Posted by GrahamRanson, Posted on 14 Sep 2011, Last updated 14 Sep 2011 | 21 comments

2 votes
3D Anaglyph (POC)

Having a pair of red/cyan anaglyph glasses laying around on my desk. So, I made a quick Proof Of Concept (POC!) to generate anaglyph 3D objects: - put on your glasses - hold device in portrait position - touch the screen to generate some 3D objects nothing more, yet. but it's cool enough, eh? :) 1 2 3 4 5 6 7 8 9 10 11 12 --[[   ---  ANAGLYPH 3D OBJECTS --- -- by finefin 2011 --   ]]--   display.... More...

Posted by canupa.com, Posted on 11 Sep 2011, Last updated 11 Sep 2011 | 3 comments

3 votes
settings.lua for storing info

settings.lua stores info in a local file. It will persis Do this somewhere in main(): 1 settings.load() Then you can get values easily: 1 2 3 4 5 6 local soundOn = settings.get('sound_on') if soundOn then   print("Sound is on") else   print("Sound is off") end You can also set values easily: 1 2 settings.set('sound_on', false) settings.set('... More...

Posted by hoan, Posted on 6 Sep 2011, Last updated 6 Sep 2011 | 10 comments

4 votes
Improved Interactive Line Drawing to Physics Body

A proof of concept on how to draw a line and have it act as a physical body. I owe MichaelAssadi a huge debt of gratitude for posting his example, it was what got me started. More...

Posted by gander, Posted on 3 Sep 2011, Last updated 3 Sep 2011 | 6 comments

0 votes
Android Friendly splash screen logic

We used this logic to add a splash screen to Android. Useful for projects that don't use Director. 1 2 3 4 5 6 7 8 9 10 11 12 13 stateCounter=0 enterFrameListener=function(event)    stateCounter=stateCounter+1    if(stateCounter==1) then        --display our splash screen        splashScreenImage=display.newImageRect("Default-... More...

Posted by jflowers45, Posted on 1 Sep 2011, Last updated 1 Sep 2011 | 0 comments

0 votes
Using Sprite Sheets for Stationary Images

If you want to actually run this code you'll want to Download the full demo package Essentially, it shows a few tips for reducing memory usage using sprite sheets 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 require "sprite" require "rackSpriteSmall"   function cleanAll()         if (rows ~= nil) then                ... More...

Posted by jflowers45, Posted on 1 Sep 2011, Last updated 1 Sep 2011 | 0 comments

1 vote
DMC Corona Library

The DMC Corona Library is a collection of classes and utilities that I have created while developing apps using Corona SDK. I thought it might be useful to others so I decided to polish it to make it into a re-usable framework. Right now there are three core files (more coming): dmc_objects - for object-oriented programming dmc_buttons - to create buttons and button groups dmc_utils - collection of useful functions... More...

Posted by dmccuskey, Posted on 1 Sep 2011, Last updated 1 Sep 2011 | 5 comments

3 votes
Floating Keyboard

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 local newLabel = ... local keys = {}   keys["2"] = true   keys["3"] = true   keys["5"] = true   keys["7"] = true   keys[" "] = true   keys["X"] = true     require("Keyboard").... More...

Posted by bruno.simoes7, Posted on 1 Sep 2011, Last updated 1 Sep 2011 | 4 comments

0 votes
Picker UI

1 2 3 4 5 6 7 8 local picker = require("Picker") local function onSelect( value )    print("Selected value: " .. value)    return true end local types = {"char", "number", "number"} local pp = { scale = 1.3, width = display.contentWidth } picker.pickerFactory( "MyInstance", types, "... More...

Posted by bruno.simoes7, Posted on 1 Sep 2011, Last updated 1 Sep 2011 | 4 comments

2 votes
Check Network Connection with Callback function table

My app has some social elements to it. Primarily, posting to Facebook and tweeting. When the user touches either action, I first wanted to check their Internet connection and wait on the result. Thanks Lerg for help. To use, you pass several arguments: The URL to check, and four function callbacks for unreachable, reachable via Wifi, via Cell, and viaOther. The calling code looks like this for example: 1 DataNet.... More...

Posted by marble68, Posted on 29 Aug 2011, Last updated 29 Aug 2011 | 1 comments

4 votes
A* Pathfinding Demo

This tutorial utilizes the great A* pathfinding code uploaded by Lerg which is found here: http://developer.anscamobile.com/code/pathfinding-module More...

Posted by codepunk_schmidt, Posted on 29 Aug 2011, Last updated 29 Aug 2011 | 10 comments

2 votes
find fonts on device

added code in comment to http://developer.anscamobile.com/reference/index/nativegetfontnames - just a simple program to run on device to list all native fonts on the device. 1 2 3 4 5 6 7 8 9 -- findfonts function to list all device fonts function findfonts()         local _H = display.contentHeight         local _W = display.contentWidth        ... More...

Posted by coynage, Posted on 29 Aug 2011, Last updated 29 Aug 2011 | 0 comments

4 votes
SceneManager

Download here : http://code.google.com/p/scene-manager/downloads/list Please direct all feedback here : http://developer.anscamobile.com/forum/2011/08/27/release-scenemanager-v10-try-it-now-alternative-director-class Hey guys. I have made a library for handling scene changes which can be used as an alternative to the director class. It features the following : 1) No memory leaks. I have tested and tested and tested... More...

Posted by Danny, Posted on 26 Aug 2011, Last updated 26 Aug 2011 | 7 comments

3 votes
Implementing Lightning Effects in Corona

I've implemented the lightning effect in Corona SDK using Lua and the algorithm as described in the following article. http://drilian.com/2009/02/25/lightning-bolts/ The result can be seen here: http://www.youtube.com/watch?v=JnRxfs87ppk The vector class I used in this file was extended from the following gist: https://gist.github.com/1006414 Write something like this to create a new lightning. You need to pass the... More...

Posted by sithu1986, Posted on 26 Aug 2011, Last updated 26 Aug 2011 | 3 comments