Share Your Code

Events

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.

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

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

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

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

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

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

2 votes
Multi-Point Pinch Zoom Rotate

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

Posted by horacebury, Posted on 2 Dec 2011, Last updated 15 Jan 2012 | 23 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

1 vote
Example MessageBox code

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

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

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

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

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

1 vote
DMC Lib - Drag and Drop

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

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

4 votes
Improved Interactive Line Drawing to Physics Body

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

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

6 votes
A* Pathfinding Demo

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

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

1 vote
Adding Image and dynamic function from array

Simple code to load image and function to be associated to its event from a table. I hope you will find it useful. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 --array with image name and function to be called on click event local circles = {{"image1","fn1"}, {"image1","fn2"}, {"image1","fn3"}}   local x... More...

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

9 votes
Rotate object with finger

I have been trying to figure out how to rotate an object with my finger by moving it in clockwise or counter-clockwise position. After much Math searching and confusion, I think I got it. Here it is: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 local function rotateObj(event)         local t = event.target         local phase = event.phase        ... More...

Posted by ChunkyApps, Posted on 14 Jul 2011, Last updated 14 Jul 2011 | 13 comments

2 votes
Draw a line

Hey, This is a way to make a user draw a line with physics, this is also a good example for math.random. Try copy pasting this code into a main.lua document. It has a walk through on how to have the user draw a physics line, with a ball rolling down. Enjoy! :) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 --(Copy paste friendly)     -- Try swiping mouse over simulator to produce random colored lines   -- Starts... More...

Posted by MichaelAssadi, Posted on 29 Jun 2011, Last updated 1 Jul 2011 | 10 comments

12 votes
Pinch Zoom XL

Update 8/10/11 - Now with more zoom! - Added tap detection. Double tap to zoom 2x, double tap again to return. Double tap from any scale to return to original scale. - Various tweaks. No longer jiggles with three fingers. Removing/replacing fingers behaves better. This is just a slight improvement of the Pinch Zoom example from the sample apps. It now supports one touch move and the zooming centers around where you... More...

Posted by duff333, Posted on 16 Jun 2011, Last updated 10 Aug 2011 | 40 comments

1 vote
Date Picker Update

This is an update to the ConoraUI code base to add features to show the user a picker interface. As shown in the sample code, there is three pickers. Time, date, and a single column custom version. The sample code is documented, and if you have any questions, comment or email me. the new code for CoronaUI is at: https://public.me.com/ix/keithmfoster/CoronaUI.zip?disposition=download+1307806413935 sample usage -... More...

Posted by keithmfoster7, Posted on 11 Jun 2011, Last updated 11 Jun 2011 | 3 comments

0 votes
Simple Multi-Event Timer

Here is a implementation of a simple multi-event timer I created which relies on the the EVERY() function. More...

Posted by phh, Posted on 1 Jun 2011, Last updated 1 Jun 2011 | 0 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

3 votes
Sanitised Touch Library

[Update v.4.3 - Bug fixes] Full example library and demo main.lua: https://files.me.com/horacebury/tmtt6p Tested on iPhone 3GS and iPad 1, both with iOS 4.2/4.3, using Mac Corona build 268. Please Note: While this library allows you to independently track as many tap/touch points as the device can handle, if you have 'Multitasking Gestures' enabled on the iPad those will override the inputs from this library and... More...

Posted by horacebury, Posted on 3 Mar 2011, Last updated 30 Mar 2011 | 1 comments

2 votes
Execution Order - An example to experience non-linear, sequential program flow

1 2 3 4 5 6 7 8 9 10 11 -- An example to experience non-linear, sequential program flow -- as event based, using transition onComplete statements -- and adding, listening for and removing Events -- -- In Corona, you may need to wait for some code to complete, -- in order for your program to flow in a prescribed sequence. -- Code with visuals such as transitions needs to send up a flare -- when its done, done here... More...

Posted by alangrus, Posted on 12 Oct 2010, Last updated 12 Oct 2010 | 0 comments

9 votes
Save and Restore State

This sample code shows how to save values to a data file and use them to restore the state of an object when the app runs again. More...

Posted by Gilbert, Posted on 20 Jul 2010, Last updated 7 Oct 2010 | 6 comments