Share Your Code

Utilities

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
Lua Class System - Object Oriented Library For Your Projects

I am sharing a small work of my own, a clean and light-weight class system I have been working on. Lua Class System (LCS) is a library for (pseudo) object oriented mechanisms. It aims to be something clean, simple to use, minimalistic so that it would easily fit in every project where object-oriented concepts might be needed. Hope some might find it useful. I am still maintaining it so small changes could occur in... More...

Posted by roland.yonaba, Posted on 20 May 2012, Last updated 20 May 2012 | 0 comments

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

3 votes
Particle Library

Particle sugar is particle library. It's api is very similar to particle candy. It implements subset of particle candy's api. you must download source and run it in simulator and read example source, this is best way to understand this library. Particle Sugar support particle type is - shape -- rect -- circle - image(s) - sprite can change several properties like - scale (in/out) - color - velocity - alpha (in/out)... More...

Posted by callin2, Posted on 17 May 2012, Last updated 18 May 2012 | 2 comments

0 votes
Insert the group object safely

I'm experienced actionscripter, and i've got stucked with the lack of really readable names of the tables in Lua. Well, it's not an issue to reconfigure the mind to avoid that mess. But, one sunny day, i found that i coud not get the the object by it's name inside the group. And that was a challendge. I tried to find the solution digging out the local code samples, but all in vain. Then, i tried to find my own way... More...

Posted by deadmorozz, Posted on 16 May 2012, Last updated 16 May 2012 | 0 comments

3 votes
Color Transition Wrapper

Since changing color smoothly seems like a task that pops up often during game development, I decided to make a wrapper function (around Corona's default transition.to) in order to make it easier. TO USE : First load the table that contains the function: 1       cTrans = require("colortransition") Then call the wrapper function as such:  cTrans:colorTransition(... More...

Posted by atoko, Posted on 9 May 2012, Last updated 9 May 2012 | 0 comments

1 vote
Invert, Horizontal Flip and Vertical Flip Physics Shapes

I recently discovered that is was very easy way to invert images, e.g: myObject.xScale = -1, will horizontally flip a display object. This works well but it will not flip any custom physics shapes assigned to the object so in order for the objects to have the correct physics the shapes need to be flipped also. Here is a function I created which will output a new list of flipped or inverted shapes coordinates from... More...

Posted by Beloudest, Posted on 7 May 2012, Last updated 7 May 2012 | 0 comments

2 votes
Validation of Auto-Renewable In-app purchases

This is a small library which can be used to validate your auto-renewable in-app purchase.. USAGE: If you want to validate without the use of an external server, the usage is as follows 1 2 3 4 5 6 7 8 local validate = require "validate" validate.start { receipt = "Your Receipt Here", password = "Your shared secret key here", listener = listener,         ... More...

Posted by Satheesh, Posted on 5 May 2012, Last updated 5 May 2012 | 1 comments

1 vote
URL safe Base64 Encoding in Lua

https://gist.github.com/2563975 A simple Base64 encoder/decoder that uses a URL safe variant of the standard. This implementation encodes character 62 as '-' (instead of '+') and character 63 as '_' (instead of '/'). In addition, padding is not used by default. A full description of the specification can be found here: http://tools.ietf.org/html/rfc4648 To encode, use: 1 base64.encode(input) where input is a... More...

Posted by Varen, Posted on 1 May 2012, Last updated 2 May 2012 | 0 comments

3 votes
OWL (Objects with Lua)

OWL is a single-module library that provides an easy way to incorporate object-oriented programming concepts into Corona SDK projects. Supports classes that produce display objects (as well as classes that produce non-display objects), and can even be used with non-Corona Lua scripts as well. Features include: More...

Posted by jonathanbeebe, Posted on 25 Apr 2012, Last updated 25 Apr 2012 | 2 comments

0 votes
Deploy collision filters easily with Corona SDK

I'm quite new to Lua as well as the Corona SDK, but I faced the collision filters pretty early. They really confused me concerning their behaviours. Finally I found those helpful sheets mentioned in the forums, but I thought it might be even cooler to have a module to handle all the bits within the code itself. So I started writing this helpful tool and thought it might be good enough for a share right here. More...

Posted by markus@sope, Posted on 25 Apr 2012, Last updated 25 Apr 2012 | 3 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
UUID v4 Generator

A pure LUA implementation of an RFC4122 UUID v4 generator. Requires no external libraries or hosted services. Also useful as starter code for restricting the namespace of the UUID. As written, it will generate duplicate UUIDs only when generated at the same time (based on 32-bit time). It's quite easy to integrate some crypto function calls to generate some pseudorandom bits with a salt of your choosing to restrict... More...

Posted by toby2, Posted on 10 Apr 2012, Last updated 10 Apr 2012 | 0 comments

0 votes
Line intersection

Another little demo with sample code to calculate the intersection point between two lines. As always from me, you'll need the mathlib.lua here (because it has the key function): https://developer.anscamobile.com/code/maths-library main.lua: 1 2 3 4 5 6 7 8 9 10 11 12 -- line intersection require("mathlib")   -- http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/   -- turn off... More...

Posted by horacebury, Posted on 8 Apr 2012, Last updated 8 Apr 2012 | 0 comments

1 vote
Simple Lua Table Save & Load

Hi, I'm not sure if anyone is going to use it, but I wanted to share this little piece of code. Currently it is designed to work with Corona XML Parser. What this code does is simply store lua table into an xml file and load it afterwards. More...

Posted by krystian6, Posted on 4 Apr 2012, Last updated 4 Apr 2012 | 0 comments

2 votes
Save data to Files ( tables/numbers/strings/boolean )

This small useful module can be used to store and retrieve values across different app sessions. You can save TABLES, NUMBERS, STRINGS or BOOLEANS. FUNCTIONS 1 2 3 4 5 preference.save preference.getValue preference.getAllValues preference.print preference.printAll USAGE AND EXAMPLES 1 2 3 4 5 6 7 8 9 10 11 12 preference = require "save_and_load_library_from_satheesh"   preference.save{a=1}... More...

Posted by Satheesh, Posted on 26 Mar 2012, Last updated 26 Mar 2012 | 1 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

7 votes
Rate It Button

I made a simple extension that makes it easier to add a "Rate it" button to a Game or App. 1 2 3 4 5 6 7 8 9 10   local rateit = require("rateit")     rateit.setiTunesURL(1234564)   rateit.setAndroidURL(1234564)     function buttonTouched(event)     rateit.openURL()     end Simple version of using it within what... More...

Posted by Richard P., Posted on 24 Mar 2012, Last updated 25 Mar 2012 | 7 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

0 votes
Script to replace object:removeSelf() with display.remove(object) in all lua files in a folder

We know it's safer to use display.remove(object) instead of object:removeSelf(). Use this perl script to automatically change all instances of xyz:removeSelf() with display.remove(xyz) in every .lua file in a folder. This was written quickly and tested on one project -- Be sure you make a backup before using it -- it will make changes to your source files. 1 2 3 4 ## Replaces all instances of object:removeSelf... More...

Posted by scott0, Posted on 22 Mar 2012, Last updated 22 Mar 2012 | 3 comments

7 votes
Collisionator - Filter Generator

I've created a tool to generate collision filters quickly for use in apps & games: http://labs.zanuka.com/collisionator3000XL/index.html * UPDATE: New version uploaded April 2, 2012. This version automatically selects the reciprocal object collision so you no longer have to tick both manually. For example if you want object 2 to collide with object 1, just select one collision in the grid and the other will be... More...

Posted by ZANUKA, Posted on 22 Mar 2012, Last updated 1 Apr 2012 | 11 comments

1 vote
"Cordinate formater" for Zwoptex, adds compatibility for ImageSheets

1. Open Zwoptex->Preferences->cordinate formats 2. Add new 3. Paste 1 2 3 4 5 6 7 8 9 10 11 module(...)   -- This file is for use with CoronaSDK™ and was generated by Zwoptex (http://zwoptexapp.com/) -- -- The function getSpriteSheetData() returns a table suitable for importing using sprite.newSpriteSheetFromData() -- -- Usage example: --               ... More...

Posted by sheraz.jamshed, Posted on 21 Mar 2012, Last updated 21 Mar 2012 | 0 comments

0 votes
Display Extensions

With so many regular operations being performed by code I thought it was time I wrote a library which helps with all this. Operations provided are: - Making a shorter global reference to the stage object - An 'indexOf' function for finding the index of a display object within a display group As with my other libraries, this will grow with time. You may notice that there are some functions designed to extend the '... More...

Posted by horacebury, Posted on 21 Mar 2012, Last updated 5 Apr 2012 | 1 comments

0 votes
Simplex noise

Hi. Another utility, this one for simplex noise. Simplex noise generates a random-ish number between -1 and +1, when given a set of 2, 3, or 4 numbers. (I suppose a braver soul might do more...) It has the useful property that "close" inputs, e.g. nearby points or similar velocities, will yield close outputs. More...

Posted by StarCrunch, Posted on 16 Mar 2012, Last updated 16 Mar 2012 | 0 comments

0 votes
Multiply-with-carry random number generator

Hi. This module lets you create lightweight (just a closure with two upvalues) instances of a random number generator, e.g. for getting per-object (deterministic) random number sequences. Some motivation is given in the middle sections here: Networking Is Hard (Part 2) 1 2 3 4 5 6 --- This module implements a multiply-with-carry RNG. -- -- Based on code and algorithm by George Marsaglia: -- [MWC](http://www.math.uni... More...

Posted by StarCrunch, Posted on 16 Mar 2012, Last updated 16 Mar 2012 | 0 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 wilson9, Posted on 13 Mar 2012, Last updated 13 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 | 0 comments

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

0 votes
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 Revaerie, Posted on 9 Mar 2012, Last updated 9 Apr 2012 | 19 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

5 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

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

1 vote
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 ScottPhillips2, Posted on 21 Feb 2012, Last updated 21 Feb 2012 | 2 comments

2 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 CluelessIdeas, Posted on 21 Feb 2012, Last updated 7 Mar 2012 | 3 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 | 1 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

7 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 and Disclaimer: I am not a mathematician and never will be. The library I've posted here has been developed to help me do things I don't really understand. I have derived all the code here either from first principles or translated it from other code posted to forums and which I can rely on working. It is... More...

Posted by horacebury, Posted on 15 Feb 2012, Last updated 11 May 2012 | 8 comments

4 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 17 May 2012 | 30 comments

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

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

5 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 | 11 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
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

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

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

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

8 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 14 Feb 2012 | 48 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

2 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 Revaerie, Posted on 14 Dec 2011, Last updated 3 Mar 2012 | 16 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

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

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

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

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

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

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

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

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 | 27 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

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

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

3 votes
Various utility functions (priority heap, pretty printer, xml parser, clamper, etc...)

I collected a small library of useful functions. Some of them aren't of my implementation, but I still included them. utils.lua------------------------------------------- -- Various utility functions and constants -- Some of these are mine (Lerg), some I found on the net -- Release date: 2011-08-25 -- Version: 1.0 -- License: MIT I guess, at least my part -------------------------------------------... More...

Posted by Lerg, Posted on 25 Aug 2011, Last updated 28 Aug 2011 | 0 comments

4 votes
Notification popup

Here's one of my utility functions from my project. It allows you to slide up notification message from the bottom and hide down after some time. Save this file as notification.lua 1 2 3 4 5 6 7 8 9 10 11 12 13 module(..., package.seeall)   function autoWrappedText(text, font, size, color, width)         --print("text: " .. text)         if text... More...

Posted by sithu1986, Posted on 14 Aug 2011, Last updated 14 Aug 2011 | 8 comments

1 vote
Thousands Separator for Large Numerical Strings

This will take in a number and outputs a string of that number with commas put in to mark the thousands. I took this from an old forum post and slightly altered it, but it seems like it would be more useful here in the code exchange. Hope it saves you a little time. Note: this will not work for numbers that are longer than 14 digits. Those will automatically be converted into scientific notation before entering the... More...

Posted by w2md, Posted on 11 Aug 2011, Last updated 11 Aug 2011 | 1 comments

2 votes
coremoter

coremoter sends accelerometer events, tuner events to corona SDK simulator over wifi. Corona simulator can also activate a textfield on device to test realtime inputing. This demo version limits the textfield activation time to 3. It support's both UDP and TCP protocol. UDP is for fast event transmission TCP is for testing when you do not have a device or you want to make some specific event by hand :-) Here is the... More...

Posted by weihua44, Posted on 3 Aug 2011, Last updated 3 Aug 2011 | 10 comments

6 votes
Corona SDK API Reference --> The App!

The Corona SDK API Reference App -- install it on your device for quick access to all the API info you need. ---> http://www.21x20.com/corona/CoronaAPIs.zip Screenshot: ---> http://www.21x20.com/corona/CoronaAPIsShot.png This just pulls the API list from the Corona SDK API Matrix and deals with it, so it's always up to date. It makes sloppy assumptions about the layout of the page, so if they ever change... More...

Posted by kennw, Posted on 22 Jul 2011, Last updated 22 Jul 2011 | 4 comments

1 vote
Subfolders for Lua, audio, xml and other files. Keep sanity.

Tired of keeping tons of files inside the root app directory? Want to group similar files in separate folders? Losing your mind while searching for a specific file? Then my solution is right for you! Concept is simple: while coding place your files in subfolders. Access them with: someModule = require('some/subfolder/some_module') That already works for the simulator, but fails when building an end... More...

Posted by Lerg, Posted on 17 Jul 2011, Last updated 29 Apr 2012 | 10 comments

2 votes
Checkbox class

I decided to write a simple checkbox class since there is noting out there. This class resembles the checkbox fuctionality of Android 2.2. It uses the default checkbox images from the Android SDK, so you will need to get them. they can be found in the the folder: SDK src\android\res\drawable-hdpi. If you do not have these images, just change the code to add your own. You can also pass in your own images to override... More...

Posted by elsereturn, Posted on 5 Jul 2011, Last updated 5 Jul 2011 | 5 comments

5 votes
Custom Particle Emitter Package

I have created a simple Custom Particle Emitter package. You can create particles of required number, size and duration with just a few lines of code. It is also possible to create decent Smoke effects and other effects with this. Feel free to experiment with the code by using different values or even some code tweaking and share it here. USAGE: 1 2 3 4 local emitter = require("emitter") local... More...

Posted by prasannakkcse, Posted on 27 Jun 2011, Last updated 28 Jun 2011 | 13 comments

0 votes
dice - A dice roller class for Corona

A simple class if you want to simulate dice rolling (like in pen and paper RPGs). Example usage: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 local dice = require("dice") -- Most compact method roll 4d6 and subtract 2 from the roll local dRoller = dice.new({dice=4, sides=6, adjust=-2}) dRoller.roll()         dRoller.reset()   -- Roll 3 6 sided... More...

Posted by puresimmer, Posted on 11 Jun 2011, Last updated 11 Jun 2011 | 0 comments

4 votes
Texture Memory Monitor

A utility to monitor texture memory usage. 2011.305 on. Require mtm.lua in your main file before any texture memory is used. At exit or another time of your choosing, call mtm.report() to get a list of what has not been freed. The following functions are monitored: display.newImage() display.newImageRect() display.loadRemoteImage() display.newText() display.remove() Set VERBOSE = true to get a list of... More...

Posted by Shenandoah01, Posted on 6 Jun 2011, Last updated 6 Jun 2011 | 31 comments

0 votes
simple cocoa style notification system

This is a simple 'cocoa' style notification system. By that I mean you can register to 'listen' for events and you can post events. This is very handy when you have controls that want to share intersting information (things like "I just went active") and you may want other people to be able to respond to it. It's an especially great pattern for one person to post and have multiple listeners. The code is almost... More...

Posted by loghound, Posted on 21 May 2011, Last updated 21 May 2011 | 0 comments

0 votes
Bezier Curve Module and SVG path to Coordinates

Hi All.. I have been looking to create coordinates from SVG path information so that I can draw something on inkscape and use it "as is" in my game code. In order to do that I first used Carlos M. Icaza code to create a module. And then I used a xml parser for lua to extract the path infomation. Right now the code only supports bezier curve but I plan to keep making improvements. Suggestions are welcome (and... More...

Posted by vinayitsite, Posted on 20 May 2011, Last updated 20 May 2011 | 3 comments

0 votes
Dynamic Text with Multiple Font Types.

A simple set of functions that was created to create Strings with alternating Font Types. This code was used as a module require: dFont.lua 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 module(..., package.seeall)   ----------------------------------------- --Display Objects ----------------------------------------- grpDFont = display.newGroup() ----------------------------------- -- FUNCTIONS... More...

Posted by vrodgers, Posted on 17 May 2011, Last updated 17 May 2011 | 0 comments

6 votes
Proper Orientation Rotation with Animation UPDATED

Current copy of that code also available at my website. http://www.pixelenvision.com/1551/coronasdk-proper-orientation-rotation-with-animation/ As you might know, when you change the orientation of an iOS device, on screen view is rotated with an animation. Current build of Corona SDK (2011.509) does support native orientation changes, but without animation. So, when you rotate the device, content on the OpenGL... More...

Posted by PixelEnvision, Posted on 16 May 2011, Last updated 13 Aug 2011 | 17 comments

0 votes
Easing library for Corona

I've really learned a lot from many of the libraries and code samples shared in the forum (I'm looking at you crawl space games!) I thought I would add my modest contribution -- a library of additional eases/transitions/tweens for corona. You can find it here https://github.com/loghound/Corona-Transitions To use simpley replace 'transition' variable with one from the library. More...

Posted by loghound, Posted on 14 May 2011, Last updated 14 May 2011 | 1 comments

6 votes
Curve Fitting - Catmull Spline

Simple curve fitting with a Catmull Spline Calculation, you can now draw a curve between 3 or more points. Use the code to generate a secondary array of points to be appended to a line. The red curve generated should not be used, instead set the steps to 5 and use the points generated to draw a line using the display.newLine() function. You should remove the code for drawing the dots and pass an array instead. 1 2 3... More...

Posted by Matthew Pringle, Posted on 8 May 2011, Last updated 12 May 2011 | 6 comments

2 votes
LuaFSM

A design pattern for doing finite state machines (FSMs) in Lua Finite state machines can be used to force (at least parts of) your code into deterministic behaviour. I wrote this code to implement generic graphical objects where the presentation and behaviour of the objects can be specified by using state-transition tables. This resulted in less code (and less bugs), a higher modularity and above all a reduction of... More...

Posted by e.cornelisse, Posted on 27 Apr 2011, Last updated 27 Apr 2011 | 1 comments

23 votes
Crawl Space Library

Hey all, I'm finally getting around to submitting this! I know many of your are already using it, but for folks who aren't following me on Twitter ( @AdamBuchweitz ), here is a link to the Crawl Space Library. It's open source and on GitHub here: http://github.com/AdamBuchweitz/CrawlSpaceLib and you will find the management site here: http://library.crawlspacegames.com where you can see the latest activity, submit... More...

Posted by AdamBucketz, Posted on 29 Mar 2011, Last updated 20 Apr 2011 | 21 comments

1 vote
webColors

Coming from an HTML background, I find it much easier to think of colors in terms of CSS color codes (e.g. #fff, #909, etc.) than decimal numbers. So, this little utility class allows one to use their current CSS color brains in their CoronaSDK projects. For example: 1 2 3 4 5     require 'x_webcolor'         a = Color()           -- a is black  ... More...

Posted by bensharpe, Posted on 29 Mar 2011, Last updated 29 Mar 2011 | 0 comments

5 votes
PropertyBag class for CoronaSDK

Hi, I have just created a new class library that you can drop into your projects and use for KeyValues, it can be found on my GIT project page at https://github.com/JayantVarma/Rating-Dialog-CoronaSDK The way to use it is simple, here's an example 1 2 3 4 5 6 7 8 9 10 11 local prop = require("property")   local propertyBag = prop:init()   --Properties created in memory... More...

Posted by JayantV, Posted on 14 Mar 2011, Last updated 21 Mar 2011 | 33 comments

3 votes
Rating Dialog to include with your projects

This is a Lua class that you can drop in your projects that will take care of displaying a dialog to request the user for rating your app. It is a first draft and this can change to include other functionality later. The source can be downloaded from GIT HUB where I have created a repository. Details on the usage and other details can be found on http://howto.oz-apps.com/2011/03/launch-rating-dialog-in-game.html... More...

Posted by JayantV, Posted on 10 Mar 2011, Last updated 10 Mar 2011 | 7 comments

2 votes
Point Reduction Code

Using a modified version of the Douglas-Puecker algorithm, using a tolerance value, check for the distance between points, rejecting points that don't fit within the tolerance. Depending on the line and tolerance, you may end up with different corner cases, thus a bit jagged line. So use different values for tolerance. look at function polySimplify Click point reduction.zip to download. Carlos More...

Posted by carlos m. icaza, Posted on 26 Feb 2011, Last updated 26 Feb 2011 | 6 comments

1 vote
Point Reduction Code

Using a modified version of the Douglas-Puecker algorithm, using a tolerance value, check for the distance between points, rejecting points that don't fit within the tolerance. Depending on the line and tolerance, you may end up with different corner cases, thus a bit jagged line. So use different values for tolerance. look at function polySimplify Click point reduction.zip to download. Carlos More...

Posted by carlos m. icaza, Posted on 26 Feb 2011, Last updated 26 Feb 2011 | 0 comments

3 votes
UUID/GUID-string generator for Corona/Lua

If you needed a unique -string-identifier in your code that was easy to generate and had global uniqueness properties and adhered to some kind of standard, then you were looking for the string versions of so-called UUID/GUIDs as described in RFC4122. There are UUID-generator OS-facilities available on all platforms, but unfortunately Corona hasn't given us access to those yet. As Ansca gets its UUID-act together... More...

Posted by FrankS, Posted on 24 Feb 2011, Last updated 24 Feb 2011 | 6 comments

5 votes
Charts

Charts is a really simple module that wraps up the Google Charts API, currently only Pie charts and QR codes are supported however I can and will add more. It just takes time. Creating the charts is simple, a QR code can be generated like this: 1 2 3 4 5 6 7 8 9 10 11 local qrCode = charts.newChart {         type = "qr",         data = "Corona Rocks!... More...

Posted by GrahamRanson, Posted on 20 Feb 2011, Last updated 13 Jan 2012 | 23 comments

12 votes
Flash's hitTestObject() emulated using contentBounds

You call this function with two images. It returns true if the images are overlapping, and false if they aren't. This is pretty handy for basic collision detection without using physics. 1 2 3 4 5 6 function hitTestObjects(obj1, obj2)         return obj1.contentBounds.xMin < obj2.contentBounds.xMax                 and obj1.contentBounds.xMax... More...

Posted by jhocking, Posted on 20 Jan 2011, Last updated 22 Mar 2012 | 15 comments

2 votes
Object along a bezier curve's path.

The sample code here demonstrates how to move an object along a bezier path. Tap on the screen four times to generate the anchor and handles. Once the curve is drawn, an object will move along the resulting path. Self explanatory. Click here to download the sample code :Bezier Carlos More...

Posted by carlos m. icaza, Posted on 10 Jan 2011, Last updated 10 Jan 2011 | 8 comments