Share Your Code

Tutorial

Sort by: Latest Additions | Most Viewed | Recently Updated | Top Rated

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

0 votes
Dynamic Content Scaling Unveiled

As I was getting my head around how Corona SDK triggers what Dynamic Content to use with display.newImageRect() function, based on what is in config.lua , device orientation and the actual physical device resolutions, I developed this small helper app. You can use it to play with your config.lua settings, change the device orientation and test on all simulated and actual devices. It will display what is going on... More...

Posted by CurvedLight, Posted on 17 May 2012, Last updated 17 May 2012 | 0 comments

1 vote
MovieClipX

MovieClipX MovieClipX (mcx) is a very slick library based off the original MovieClip library for Corona SDK. It adds a few very awesome features including More...

Posted by iGARET, Posted on 24 Apr 2012, Last updated 24 Apr 2012 | 0 comments

0 votes
Jump without the physics engine

well i started looking for a way to create a game without using the physics engine and letting the player jump and i used the hit test that was provided from one of the users in the website now the logic is that you need to play with the player y value to be able to control the jump and the falling down have fun with the code i hope you like it in the get hub you need to go to the download to get the file More...

Posted by mtayyar, Posted on 24 Apr 2012, Last updated 24 Apr 2012 | 4 comments

2 votes
Shortest Path Through A Concave Polygon With Holes

This program draws the shortest path between two points inside any polygon (with or without holes). The source for this program is C code by Darel Finley found at http://alienryderflex.com/shortest_path/ and translated into Lua by horacebury and me. The program lets you draw a bounding polygon that is either a convex polygon or a concave polygon. Other polygons can be drawn within the bounding polygon to create “... More...

Posted by brucemartin, Posted on 19 Apr 2012, Last updated 20 Apr 2012 | 8 comments

0 votes
Polygon fill and Point in Polygon detection

Source of my inspiration: http://alienryderflex.com/tutorials.shtml local widthheight, isclosed, isperpixel = 1, false, false local widthheight, isclosed, isperpixel = 10, true, true NOTE: The functions in this demo are provided in the mathlib.lua found here: More...

Posted by horacebury, Posted on 5 Apr 2012, Last updated 5 Apr 2012 | 2 comments

3 votes
Cat-mull-rom open and closed

So, got back into the old bezier stuff again and figured it might be fun to try and get the curve passing straight through the control points. Makes it more useful for plotting courses for game characters, because players are not going to be drawing lines and placing control points - they'll just drag out a path or whatever and the character should traverse it, etc... More...

Posted by horacebury, Posted on 25 Mar 2012, Last updated 25 Mar 2012 | 0 comments

0 votes
Wellen

Many, many (too many) years ago, I was in love with my Acorn Archimedes and on an Acorn Computer Magazine cover disc was a little BBC BASIC program called Wellen. It was a simple row of red circles, connected by elastic bands - well, green lines. Though simple, it was great fun to see how the mathematics worked with these springy balls and to throw them around the screen. This is the Corona Physics version - using a... More...

Posted by horacebury, Posted on 24 Mar 2012, Last updated 24 Mar 2012 | 0 comments

12 votes
Texturemapped Raycasting Engine

As a follow up to my original code share of the Corona port I did of my 2D raycasting engine, texture mapped walls have been added. This was achieved using sprite sheets. The downside of this is the frame rate takes quite a hit compared with the flat filled walls shown in the original sample. I know I can optimise how I use sprites in this demo, but I still think more needs to be done to get the frame rate up -... More...

Posted by Jesder, Posted on 10 Mar 2012, Last updated 10 Mar 2012 | 17 comments

5 votes
3D Object Rendering

A new example I wanted to share with you guys, was some 3D Object rendering. Not quite as exciting at the raycasting sample I posted a few weeks back, but still interesting enough I think ;) Glenz: Wireframe: More...

Posted by Jesder, Posted on 2 Mar 2012, Last updated 2 Mar 2012 | 4 comments

2 votes
Simple draggable fan demo 2

Due to the Mobile Me / iCloud motions going on, the original Simple draggable fan demo is no longer available. There were considerable bugs with it, so I thought I'd write it from scratch with more reliable code. The main.lua is below, but please go here to get the mathlib.lua, which it requires: mathlib.lua: http://developer.anscamobile.com/code/maths-library main.lua: 1 2 3 4 5 6 7 8 9 -- simple draggable fan demo... More...

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

0 votes
Ultra Simple Parallax Scrolling

So this is a parallax scrolling module that will handle up to 5 "layers" of parallax. This is made for landscape orientation, but you should be able to just flip a few things in the file and make it work for vertical as well. You can insert as many images as you want within each layer (minimum of 3, I don't think it'll work properly with only 2). Also, all images within each layer will need to be the exact same size... More...

Posted by 003naveen, Posted on 26 Feb 2012, Last updated 26 Feb 2012 | 1 comments

0 votes
Super Simple IAP in 1 Line

I use this in pretty much all my projects, and it works perfectly. I stripped out some of my own custom code, and left it with all the essentials that you need. Please let me know if it works for you. When you try to fetch the price of an item, it seems to be a hit or miss for me. I've tried multiple devices, and I'm not sure why it only works sometimes. Apples IAP servers are pretty bad, and there's lots of small... More...

Posted by 003naveen, Posted on 23 Feb 2012, Last updated 23 Feb 2012 | 16 comments

2 votes
LunarAds | Promote Apps | Monetize Traffic | Measure Performance

Hi Everyone, Our new ad network SDK for Corona developers is ready for the masses! https://lunarads.com/signup/ It's been running solid for over 2 years in-house and we think it's time to let you guys take advantage of it! We are opening this up to Corona developers first (because we love you guys so much!) Below is the simple Corona wrapper that installs in seconds and lets you begin pushing Lunar ads. More...

Posted by MBD, Posted on 15 Feb 2012, Last updated 17 Feb 2012 | 17 comments

5 votes
Fractal Art

This is a sample that will render some fractal art using lua and the Corona API. A few years back, I took an interest in fractals and was curious about how to make them. This sample is a port of a C++ sample I wrote back then, showing how to create Mandelbrot and Julia sets. Here you can toggle between them by pressing the toggle button in the lower right corner. There is a small delay on start up as it calculates... More...

Posted by Jesder, Posted on 14 Feb 2012, Last updated 14 Feb 2012 | 1 comments

7 votes
Page Curl

One of the Tutorials that Jonathan Beebe wrote showed how to implement a page curl effect for your apps. Unfortunately there are some problems with that short example and a number of people have requested fixes. I've modified Jonathan's code heavily and modularized it so people can implement page curl with just a couple of lines of code. I've also fixed the issue that some people were experiencing. Here is an... More...

Posted by KenRogoway, Posted on 14 Feb 2012, Last updated 14 Feb 2012 | 15 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
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

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
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 | 20 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
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
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 | 3 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 | 43 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 | 6 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

8 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 | 9 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 | 20 comments

1 vote
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 | 7 comments

3 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

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

2 votes
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 | 9 comments

6 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 | 14 comments

1 vote
Recipes App using Director and ScrollView

Features a menu system and an implementation of the scroll view class. Also uses the Director class for changing screens. Great for beginners to learn with. Feel free to also check out the video tutorials that describe how to create this app from scratch. Again, these videos are great for beginners looking to learn lua and corona from scratch.... Files: http://www.mediafire.com/?55vdl521hbg41k2 Video Tutorials (... More...

Posted by mf, Posted on 22 Aug 2011, Last updated 10 Sep 2011 | 7 comments

4 votes
Dynamic Module Loading

“Dynamic Module Loading”. Sounds fancy but in fact it really isn’t. Whenever I start a new project and am in the design phase, I look for areas of the design that can benefit from being data driven and a way to support an extensible plugin model. The code I’m about to show you here does just that. Again, not rocket science but I think you’ll see that it can help you quite a bit. The whole concept behind this lies... More...

Posted by codepunk_schmidt, Posted on 17 Aug 2011, Last updated 17 Aug 2011 | 2 comments

0 votes
Simple Loading Screen

This is a simple loading screen logic which you can use if you are loading lots of graphics which slows down your game loading. This was asked by @fufuhwawa and I think this will be handy for others also. Note: This is just a sample to convey the idea so the screen won't look that impressive. 1 2 3 4 5 --creating main group all display objects will be loaded to it local mainGRP = display.newGroup()... More...

Posted by renvis@technowand, Posted on 11 Aug 2011, Last updated 11 Aug 2011 | 13 comments

2 votes
Object drag direction

The below code shows the direction in which an object is tragged. The directions shown are - UP - UP LEFT - UP RIGHT - LEFT - RIGHT - DOWN - DOWN LEFT - DOWN RIGHT This is useful in cases where you need to change the image based on the direction of object or if you need to code a joystick. 1 2 3 4 5 6 7 8 9 10 --to store previous position of x and y local prevx = 0 local prevy = 0   local circle = display.... More...

Posted by renvis@technowand, Posted on 1 Aug 2011, Last updated 1 Aug 2011 | 1 comments

0 votes
Keeping score aligned

Hey, i don't know if someone has posted something similar to this, but I couldn't find one, so I wrote my own. If it's already out there somewhere, then sorry -- I just thought this could help the community. Basically, it is an external module that you require in to your code called length.lua. length.lua 1 2 3 4 5 6 7 8 9 10 11 12 13 module(..., package.seeall)   function width(y,t)  ... More...

Posted by mdcapps, Posted on 29 Jul 2011, Last updated 29 Jul 2011 | 7 comments

7 votes
Audio Pitch / Turntable Example

A basic turntable example to demonstrate the "hidden" OpenAL audio pitch feature in Corona and possibly the smallest turntable code ever^^ You can change the music's pitch in realtime by turning the knob / turntable. Requires only 20 lines of code. Use any "knob" image as a graphic and any sound file of your choice or download the .zip file here (all media included): DOWNLOAD main.lua (requires two files named "knob... More...

Posted by x-pressive.com, Posted on 28 Jul 2011, Last updated 28 Jul 2011 | 5 comments

5 votes
ALexplorer

Exercises some of Corona's "secret" OpenAL features as described in our blog entry The secret/undocumented audio APIs in Corona. Also uses simple sprite animation and some Widgets (requires Corona build 579 or so). Please use with care. Support is very limited; the Corona OpenAL APIs used here may change or be removed entirely. Additional Information: More...

Posted by snarla, Posted on 27 Jul 2011, Last updated 19 Aug 2011 | 0 comments

0 votes
Math function optimization

This code shows how to use a lookup table to optimize the computation of sin values. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 --[[ Math functions optimization with a lookup table This code compares the speed of running a global sin function with a locally cached one and with a sin lookup table.   Conclusion: If you are only using whole numbers, the lookup table is SIGNIFICANTLY faster than the other two methods.... More...

Posted by amirfl7, Posted on 23 Jun 2011, Last updated 23 Jun 2011 | 0 comments

0 votes
Puzzle Piece Game Logic

1 2 3 4 5 6 7 8 9 10 11 12 ---by: James Timberlake ---Please use this for your own purposes. This is some code I found may be useful for everyone.Ti ---This is an example of creating pieces of the same image using sprite sheets --This can be used for more than game pieces, but that was the only way I knew of describing this. --Note: making pieces more than 400 will give a significant amount of time before loading... More...

Posted by jamestimberlakejr, Posted on 12 Jun 2011, Last updated 12 Jun 2011 | 13 comments

9 votes
How to make an Angry Birds catapult

Catapults like that found in Angry Birds and Hot Cross Bunnies are a staple weapon in the arsenal of any mobile gamer. We thought we'd share with you how to put together a slingshot catapult that looks great and feels authentic. More...

Posted by Fixdit, Posted on 18 May 2011, Last updated 25 Jan 2012 | 23 comments

4 votes
print() function from device *small dirty hack*

For those who are looking for quick way to implement print function to do quick debugging while testing on device, can use following method Open a terminal window on your mac, and type following command 1 nc -l -k 1234 This creates quick dirty listener using builtin utility nc (netcat) at port 1234 now in your Corona code, define following function and use it to send string data to above terminal :) 1 2 3 4 5... More...

Posted by chinmay.patil, Posted on 1 May 2011, Last updated 1 May 2011 | 4 comments

4 votes
Tables in Lua: Dictionaries AND Arrays

Most people understand how to use Lua tables like arrays in other programming languages. However, Lua tables can also be used like dictionaries (aka hash tables, aka associative arrays) which is a very powerful concept. More...

Posted by jhocking, Posted on 23 Jan 2011, Last updated 28 Jan 2011 | 5 comments

12 votes
Object-Oriented Sample Game Framework

I put together a basic game framework to show novice programmers how to organize your code in a modular, object-oriented way. You can download the project from here: http://www.box.net/shared/uz5beg19h8 I wouldn't necessarily recommend starting here if you are totally new to programming, but if you have a little previous familiarity with object-oriented programming then this is a good head-start in using Corona. I... More...

Posted by jhocking, Posted on 20 Jan 2011, Last updated 11 May 2011 | 31 comments

5 votes
Bezier Curves in Corona

Finally ! Bezier segment manipulation using Corona SDK. This is a sample of how to manipulate a cubic bezier segment. Touch the screen to draw the four points (anchor1,handle1,handle2,anchor2) then manipulate the curve. I cleaned up the code as much as I could. It is not optimized. Feel free to make changes, amplifications and updates and share with the rest of us. You can download the code at Bezier Code I tried it... More...

Posted by carlos m. icaza, Posted on 11 Dec 2010, Last updated 11 Dec 2010 | 19 comments

2 votes
D-Pad Demo

This is a demo for controlling a object with a D-Pad. -Gamexcb http://www.mediafire.com/?2jg2ep54ay9ee1t More...

Posted by Gamexcb, Posted on 20 Oct 2010, Last updated 20 Oct 2010 | 1 comments

2 votes
Display Objects and Texture Memory

This tutorial code is used to demonstrate Display Objects and their affects on Texture Memory. You can view a two part video of this tutorial at: http://www.youtube.com/watch?v=_oWWWueFl8I More...

Posted by Tom, Posted on 5 Oct 2010, Last updated 7 Oct 2010 | 2 comments