Share Your Code

Latest Additions


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

2 votes
Storyboard Goto (no initial delay)

This fix eliminating the initial delay explained in this thread: http://developer.anscamobile.com/forum/2011/12/03/initial-delay-storyboardgotoscene In your main.lua override the gotoScene function 1 2 3 4 5 -- require controller module  local storyboard = require "storyboard   -- override goto function storyboard.gotoScene = require "goto" Add file goto.lua 1 2 3 4 5 6 7 8 9 10 -- Project:... More...

Posted by Johantd04, Posted on 13 Mar 2012, Last updated 13 Mar 2012 | 6 comments

1 vote
Sprite Sheet Packer for Corona ImageSheets

Sprite Sheet Packer (Windows Only) is a FREE and fully featured tool by Nick Gravelyn for combining multiple individual images into a single, efficiently laid out image. Get it here: http://spritesheetpacker.codeplex.com/ This SpriteSheetPacker.lua module by Michael Wilson (me!) takes the Output Text files SSP creates and creates a table that works seamlessly with Corona's new ImageSheets... 1 2 3 4 5 6 module... More...

Posted by no2games, Posted on 13 Mar 2012, Last updated 13 Mar 2012 | 1 comments

5 votes
Tar Extraction Module

Hey guys, I am aware that loads of you have been looking for a way to extract archives with Corona for a long time now. I am planning on implementing more archive support for corona in C/objective c but more info on that later. So for now, here is a solution done in pure lua. From benchmarking it took 1.3 seconds to extract a 10mb tar archive. I created the test tar archive using a mac app named "betterZip" however... More...

Posted by Danny, Posted on 13 Mar 2012, Last updated 13 Mar 2012 | 1 comments

1 vote
Simple Progress Bar

This is a simple and easy to integrate progress bar which includes "heartbeat" animation to reflect activity even when not updating. More...

Posted by bob.dickinson, Posted on 12 Mar 2012, Last updated 12 Mar 2012 | 1 comments

2 votes
Transition Manager 1.0

Transition Manager 1.0 Syntax: instance.Start(object, time, xValues, yValues) Example: 1 2 3 local transman = require "transman" local square = display.newRect(50, 50, 0, 0) transman.Start(square, 500, {50, 100, 150, 200, 250}, {50, 100, 150, 200, 250}) Parameters: - object: A display object that will be the target of the transition. - time: A number that specifies the... More...

Posted by joelwe, Posted on 11 Mar 2012, Last updated 14 Mar 2012 | 1 comments

0 votes
easy event handling in your classes (tables)

Having been fed up of passing callbacks into functions I thought that there had to be a better way. Wouldnt it be useful for any object to be able to register listeners and dispatch events? now you can. :-) 1 2 3 4 5 6 require "lib-events"   myClass={} cLibEvents:instrument(myclass) -- consumers of myclass can use addEventListener -- myclass can use dispatchEvent lib-events.lua 1 2... More...

Posted by open768, Posted on 11 Mar 2012, Last updated 21 Mar 2012 | 0 comments

5 votes
DMC Lib - Trajectory

dmc_trajectory is a module which provides a method to have objects follow ballistic trajectories without using the physics engine. It's as simple as setting up an object transition with a few Corona parameters. Features simple, single trajectory method object can be auto-rotated to match the slope of the trajectory path additional methods to get trajectory calculations Documentation Quick Guide: http://docs.... More...

Posted by dmccuskey, Posted on 11 Mar 2012, Last updated 1 Feb 2013 | 3 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 | 20 comments

1 vote
Stopwatch Timing Class

Current Version: 1.2 Stopwatch is an easy way to create and manage timers (not the performWithDelay kind!), clocks, and any other timekeeping your app might require. Count down to from any number to 0, count up to infinity, pause and resume, and more! 0. Require stopwatch Simply add stopwatch.lua to your project folder, and require it into the files you need it like so: 1 local stopwatch = require "stopwatch... More...

Posted by Kyle Coburn, Posted on 9 Mar 2012, Last updated 9 Apr 2012 | 28 comments

2 votes
Conway's Game of Life for Corona SDK

A quick code share to create Life within Corona. This is great learning example to master 2D arrays and to soak up some game logic roots! The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. Check out the full story on my blog at Conway's Game of Life for Corona SDK More...

Posted by croisened, Posted on 9 Mar 2012, Last updated 9 Mar 2012 | 0 comments

0 votes
Basic ladder control for sprite

I have been trying to figure out how to do this and finally put all the pieces together (sort of). I saw a several questions about this in the forum, and never really found a solid answer, so I thought I would share the code I worked up. The basic answer is "When player collides with ladder, turn gravity off". But your 'up' button needs to track what state the gravity is in or the player movement can get wonky.... More...

Posted by sds65805, Posted on 9 Mar 2012, Last updated 9 Mar 2012 | 0 comments

0 votes
Detect display size

First put this in your config.lua: 1 2 3 4 5 6 7 application = {         content = {                 width = 320,                 height = 480,                 scale = "letterbox"         }, } now put this in the top of your main... More...

Posted by g6dev.mk, Posted on 8 Mar 2012, Last updated 8 Mar 2012 | 0 comments

6 votes
Streaming "News Ticker" (Twitter Feed or Online Text File)

I wrote the following bit of code for an app I'm working on where I wanted to have a "news ticker" scroll along the bottom of the home screen that I could change remotely. I also briefly considered streaming the most recent tweets from a Twitter account - so I'm including that code as well. See the commented-out text below for notes on how to change the ticker text or Twitter feed that displays. If you copy this... More...

Posted by jasonschroeder, Posted on 6 Mar 2012, Last updated 6 Mar 2012 | 24 comments

1 vote
Pauseable Transitions, unified timer and transition module, can replace built-in

Here is yet-another pausable transition library. I call it "ctrans", short for "custom transitions". It is different in that it keeps track of all transitions internally, rather than just tag on data to tween objects. This keeps the size of the tween objects small and allows you to perform actions on a large set of transitions with a simple command. More...

Posted by kenneth34, Posted on 4 Mar 2012, Last updated 10 Apr 2012 | 11 comments

2 votes
A useful CROP LIBRARY

So this is a small Crop Library I put together. Hope you guys find it useful :) Feel free to play around with the code. Do comment below if you have any modifications. Here's a screenshot USAGE 1 2 crop = require "cropper_library_from_satheesh" crop(img,options) OPTIONS 1 2 3 local options =                         --  POSSIBLE... More...

Posted by Satheesh, Posted on 3 Mar 2012, Last updated 26 Mar 2012 | 12 comments

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

8 votes
Facebook helper/support module

This library creates a wrapper around the Corona SDK Facebook API support. Using this library will streamline your Facebook client logic and make it easier to debug and to catch/handle errors (well, it did for my anyway, YMMV). The biggest feature is probably that it supports Facebook functionality in the simulator (for most things). More...

Posted by bob.dickinson, Posted on 2 Mar 2012, Last updated 2 Mar 2012 | 23 comments

1 vote
sequencing transitions

Hi I was trying to sequence the transition components of a complex grouping of objects. It was getting a real pain to have to coordinate callback functions. So I wrote a helper class to painlessly sequence the transitions. only one callback - the one called when its all finished enjoy! 1 2 3 4 -- VERSION -- -- This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. -- -- http://... More...

Posted by open768, Posted on 29 Feb 2012, Last updated 29 Feb 2012 | 3 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 10 11 -- simple draggable... More...

Posted by horacebury, Posted on 29 Feb 2012, Last updated 21 Dec 2012 | 2 comments

1 vote
Audio Pan and Pitch

Adds pan and pitch capabilities to the built-in audio class. . 1 2 3 4 5 6 7 8 9 10 11 12 13 ---------------------------------------------------------- -- Abstract:    SuperAudio - Extends the built-in audio --                              class to provide pan and pitch capabilities... More...

Posted by mrgoose, Posted on 28 Feb 2012, Last updated 29 Feb 2012 | 4 comments

8 votes
Scrollable Lists (Scrollview alike)

I've recently created a module for lists for one of our apps and I think it is worth sharing. It basically creates lists, both vertical and horizontal using strings (for text lists) or display objects (possibly groups). It is highly customizable. Lists behave like iOS lists where one can scroll farther than the end, and upon release the lists gets back to the last element. Also has momentum for fast scrolling of... More...

Posted by RicardoGraca, Posted on 28 Feb 2012, Last updated 28 Feb 2012 | 22 comments

2 votes
MapViews on Android using Google Maps API & Javascript

Hi Everybody, I don't know about you, but I've grown desperate waiting for Android MapViews, so I've taken matters into my own hands and come up with what I think is a pretty decent workaround, using HTML, JavaScript, and a WebPopup. Obviously, this isn't a perfect replacement for native mapViews, but it can help get us through in the meantime, and it might come in handy later for devices like the Kindle Fire -... More...

Posted by jasonschroeder, Posted on 27 Feb 2012, Last updated 1 Mar 2012 | 11 comments

3 votes
Asteroids

I got hit with the urge to write the Atari classic Asteroids using the physics engine and a "no button" touch controls. So, here's the source code. It's really messy, not object oriented but it shouldn't throw too many errors and I've tried to handle the object removal etc reasonably well. There are some principles which n00bs could learn from and some which you should avoid, but all in all if you were to take the... More...

Posted by horacebury, Posted on 27 Feb 2012, Last updated 28 Feb 2012 | 12 comments

1 vote
Code Genie

This is some code I put together to create a lot of sequential lines of code very fast. Basically code to make more code but faster. The output is printed to the terminal for you to copy and paste so you need to open the main.lua with Corona Terminal open. Although you probably wont be using this source code in your project, hopefully it will speed up the process of making your apps. The finished product would look... More...

Posted by chandler767, Posted on 27 Feb 2012, Last updated 27 Feb 2012 | 1 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 naveen_pcs, Posted on 26 Feb 2012, Last updated 26 Feb 2012 | 2 comments

2 votes
Storyboard setScene event

This is a really small library to add an event to the list of events fired by the storyboard api. I found that I wanted to have createScene fired on every gotoScene call simply to prepare the scene so it looked right prior transitioning onto the screen. Of course, this doesn't happen, so I created setScene in it's place. setScene will only fire when createScene is not fired, meaning it can safely be called from... More...

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

4 votes
Super simple Lua Table Save and Load from file functions

This is about as simple as it gets for reading and writing your game data files in Corona SDK/Lua. It uses the JSON library to do the magical data parsing so you don't have to worry about it. Start with a table. End up with the identical table. USAGE: myTable = {} myTable.musicOn = false myTable.soundOn = true saveTable(myTable, "myTable.json") Then to read it back in: myTable = loadTable("myTable.json") This... More...

Posted by robmiracle, Posted on 23 Feb 2012, Last updated 23 Feb 2012 | 38 comments

3 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 naveen_pcs, Posted on 23 Feb 2012, Last updated 23 Feb 2012 | 30 comments

4 votes
Amazon S3 REST API implementation for Corona

This module supports access to the Amazon Simple Storage Service (S3), a popular cloud-based storage platform, from Corona SDK applications. It supports both synchronous and cancellable asynchronous requests to S3. For more information, see: http://aws.amazon.com/s3/ http://www.anscamobile.com/corona/ More...

Posted by bob.dickinson, Posted on 22 Feb 2012, Last updated 24 Feb 2012 | 33 comments

2 votes
GUID Creation Module

I needed a way to generate unique IDs for something I was working on, and since Corona doesn't have built in support for guids, and since the only other thing out there had dependencies, I wrote my own. I can't say that they adhere entirely to the spec., but they look right, and they're guaranteed to be unique, so it was good enough for me. They looks like this: DA3C1235-EAE1-2524-7798-63D2D8EBC487 846521A4-D962-... More...

Posted by drbigfresh, Posted on 21 Feb 2012, Last updated 21 Feb 2012 | 3 comments

3 votes
Android screen sizes and names list

In some cases it's useful to know the actual device in which our applications are running. This can be used to fix specific bugs or deal with specific devices in a certain way. This is an attempt to gather a list of device names as they are found on the actual devices. The list also includes screen sizes, commercial names and may be expanded to include other info if required. The main goal is to know the actual... More...

Posted by RicardoGraca, Posted on 21 Feb 2012, Last updated 23 Aug 2012 | 11 comments

4 votes
Smooth Bezier Path (Curve) Fitting and Point Reduction

This was my attempt at using the Ramer–Douglas–Peucker algorithm for point reduction and Philip J. Schneider Digital Curve Fitting function (which has still not been implemented, but you can Google "fit_cubic.c" to find out more). I'm all about nice smooth simplified paths, but the only thing I've done so far is got the RDP point reducing algorithm complete and the basics of Tulleken's articles listed below. Please... More...

Posted by ETdoFresh, Posted on 16 Feb 2012, Last updated 16 Feb 2012 | 2 comments

19 votes
Ad Mediator for Corona®

Ad Mediator for Corona is a client-side ad mediation module very much like AdWhirl. It supports admob, inmobi, inneractive, tapit, madvertise, herewead and house ads out of the box and can be extended easily by using a simple plugin framework. More...

Posted by deniz, Posted on 16 Feb 2012, Last updated 30 Aug 2012 | 107 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 | 20 comments

9 votes
Maths Library

NOTE: I have commented out the line at the top, so you now only need to require the mathlib in your main.lua NOTE: For a full list of my libraries and samples see here: http://springboardpillow.blogspot.co.uk/2012/04/sample-code.html NOTE: I am using DEPRECATED to show that some functions are no longer relevant or correct. NOTE: Added new dot product, cross product and polygon area functions. More...

Posted by horacebury, Posted on 15 Feb 2012, Last updated 5 Mar 2013 | 31 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

15 votes
Raycasting Engine

Back in 1997, I wrote a raycasting engine in Turbo Pascal. It had a number of features and was heading towards being turned into a fully fledged game engine. That never happened. But since then, as I move between development platforms, I like to port a cutdown version of it to help make me familiar with the syntax and API on the new platform. Here is a basic raycasting engine written in LUA with the Corona SDK. More...

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

11 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 | 16 comments

4 votes
Device Metrics for scaling based on screen size

In trying to scale my application to various sized devices from an iPhone to an iPad and everything in between (particularly the Kindle Fire and Nook Color), I have been frustrated by the lack of Corona support for physical screen size. If you want an application to truly scale (and not just be a sized-up phone app when you run on a tablet), then you have to be aware of the physical size of the screen. More...

Posted by bob.dickinson, Posted on 8 Feb 2012, Last updated 8 Feb 2012 | 21 comments

8 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 3 Mar 2012 | 8 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 | 6 comments

6 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 22 May 2012 | 44 comments

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

2 votes
Much Improved 'dump' function and XML simplify

UPDATE: This post now has a lot more functionality, described just before the code... UPDATE: Slightly improved the list parsing in 'simplify'. 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... More...

Posted by horacebury, Posted on 2 Feb 2012, Last updated 30 May 2012 | 14 comments

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

7 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 | 23 comments

3 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 | 2 comments

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

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

2 votes
Ad Manager for Corona

******************************************************************************************************** This module is obsolete. Please use Ad Mediator for Corona instead. It is an ad mediation module very much like Adwhirl. Ad Mediator for Corona: http://developer.anscamobile.com/code/ad-mediator-corona ********************************************************************************************************... More...

Posted by deniz, Posted on 25 Jan 2012, Last updated 16 Feb 2012 | 11 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 | 2 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 | 4 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 iTrain Dev, Posted on 20 Jan 2012, Last updated 20 Jan 2012 | 4 comments

5 votes
Follow (and avoid) 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 12 local fin = {} local radians = 180/math.pi  --> precalculate radians   fin.distanceBetween = function ( pos1, pos2 )          local sqrt = math.sqrt  ... More...

Posted by canupa.com, Posted on 18 Jan 2012, Last updated 29 Apr 2012 | 15 comments

5 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 Feb 2012 | 9 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

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

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

2 votes
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] [NOTICE: A maintainable post for the up to date mathlib.lua is available here: http://developer.anscamobile.com/code/maths-library I have not removed it from this post as it may change beyond this sample's use.] More...

Posted by horacebury, Posted on 30 Dec 2011, Last updated 15 Feb 2012 | 18 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 13 Feb 2012 | 6 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 | 2 comments

12 votes
Text Wrapper Class

There are two main usages of the module: You can wrap any text to a desired width, the height will be appointed automatically. You can wrap any text to a desired width and height, the font-size will be appointed automatically. This feature is very useful if you want a text shown in a spezific frame without knowing its lenth. If it is fetched from internet or entered by the user for example. . Adjustable... More...

Posted by sunmils, Posted on 22 Dec 2011, Last updated 14 Oct 2012 | 68 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 | 3 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 se24vad, Posted on 16 Dec 2011, Last updated 19 Dec 2011 | 2 comments

4 votes
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 Kyle Coburn, Posted on 14 Dec 2011, Last updated 3 Mar 2012 | 18 comments

2 votes
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 | 3 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 Varen, Posted on 4 Dec 2011, Last updated 5 Dec 2011 | 2 comments

3 votes
Multi-Point Pinch Zoom Rotate

I have recently posted a much better implementation with completely revised multi-touch management: http://developer.coronalabs.com/code/pinchzoom-made-real-easy Previous example: https://developer.anscamobile.com/code/pinch-zoom-rotate Full sample code: https://dl.dropbox.com/u/10254959/PinchZoomRotate.zip More...

Posted by horacebury, Posted on 2 Dec 2011, Last updated 13 Nov 2012 | 61 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 | 2 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 | 6 comments

7 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 | 3 comments

3 votes
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 | 4 comments

3 votes
RagDoll example

Code: http://content.screencast.com/users/HoraceBury/folders/Jing/media/b5d1152f-54d3-4811-b584-bf08f27d5341/Ragdoll.zip?downloadOnly=true Swf Video: http://www.screencast.com/users/HoraceBury/folders/Jing/media/ab4587e4-6ff6-4cbe-90c5-9c150cdef424 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... More...

Posted by horacebury, Posted on 22 Nov 2011, Last updated 2 Aug 2012 | 23 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

3 votes
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 | 7 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

4 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 | 32 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 | 5 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

9 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 | 41 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 | 3 comments

1 vote
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 mightE, 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 mightE, Posted on 28 Oct 2011, Last updated 28 Oct 2011 | 2 comments

3 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 | 12 comments

3 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

5 votes
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 | 34 comments