Shared Code

Please Note: This code exchange has been deprecated. You can still browse, but the code here may be out of date. We strongly recommend you visit and contribute your code to our new code exchange.

Latest Additions


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

Listener Auto Remove

I have quite a few listeners being added in my game. Many of these are for child display objects to listen for custom events dispatched by parent display objects or even storyboard scene objects. I use this mostly for cleanup, etc. More...

Posted by horacebury, Posted on 13 Jan 2014, Last updated 13 Jan 2014 | 0 comments

rgb

rgb is a module used to set object colors by using color names. to use copy code below save as rgb.lua then require module local rgb = require'rgb' then to set color use object:setFillColor( rgb.color( "blue" )) or what ever color you want to use 1 2 3 4 local M     -- color values taken from http://www.avatar.se/molscript/doc/colour_names.html               M = {... More...

Posted by jstrahan, Posted on 12 Jan 2014, Last updated 12 Jan 2014 | 1 comments

Display group indexOf

Display groups do not support the regular table.indexOf functionality, so if you want to know which index a display object has within it's parent display group you'll need to loop manually. This function adds the search to the table.indexOf function, using the .numChildren property to identify display groups: 1 2 3 4 5 6 7 8 -- extends the table.indexOf to work with display groups local _indexof = table.indexOf... More...

Posted by horacebury, Posted on 11 Jan 2014, Last updated 11 Jan 2014 | 0 comments

Range Slider

This Range Slider is a Two Handles Sliders with maximum and minimum values if you want. This is the same code as the widget.slider from the corona guys i just made some changes and added the ability to use as a double handle slider. It's easier to make ranges selections this way and if someone find any error please let me know. to download the code go Github. The link to take look on youtube and see woking http://... More...

Posted by R4T40, Posted on 10 Jan 2014, Last updated 10 Jan 2014 | 1 comments

Stroke for Text Fonts

Got the base function from the forum and improved it a bit: http://forums.coronalabs.com/topic/8895-stroke-on-text/ PS. note that parameters "color" and "strokecolor" need to be tables such as {1,1,1}. Follows the function: 1 2 3 4 5 6 7 8 local newText = function(str, font, size, color, strokewidth, strokecolor)     local bg     local t = display.newGroup()     t.... More...

Posted by marcior, Posted on 11 Dec 2013, Last updated 11 Dec 2013 | 0 comments

3D skybox

Skybox Self-contained skybox module for Corona SDK Note that this is Graphics 2.0 only - for some reason the version compatibility box below does not accept my value, so a build number of higher than 2013.2000 is needed. Find the library, several sample skyboxes and the latest help files at the github link. Latest update features: Can now be a group, container or snapshot. More options for specifying the faces of... More...

Posted by rakoonic, Posted on 9 Dec 2013, Last updated 9 Dec 2013 | 1 comments

Depth / sortable display group

A library that extends the normal display group to allow you to sort the children within it. You can sort by any property of the children (including added ones, for example a Z or DEPTH value), or you can supply your own custom sort function. Find the library, the sample project and latest help text in the github link above. Setting up Just require the 'sortable_group' group. You only need to do it once, and you don... More...

Posted by rakoonic, Posted on 9 Dec 2013, Last updated 9 Dec 2013 | 0 comments

Super colorful print() function

This piece of code overrides the print( ) function to a super colorful one. All you need to do is require the module in your code, and now you get extra information with every print( ) call as well as colours. It will print out your original string as well as: Function name Invoking file path Line number More...

Posted by josellausas, Posted on 3 Dec 2013, Last updated 3 Dec 2013 | 0 comments

Continue using setReferencePoint() to set new anchor points in Graphics2.0

Requiring this function will re-enable obj:setReferencePoint() for the following objects: *display.newGroup *display.newImageRect *display.newImage *display.newRect *display.newRoundedRect *display.newText *display.newEmbossedText *display.newCircle *display.newLine *display.newSprite Just include the lua file in your project, and then call require("refPointConversions") at the start of main.lua. More...

Posted by AlanPlantPot, Posted on 29 Nov 2013, Last updated 29 Nov 2013 | 0 comments

Choosing Color Values for Graphics 2.0 Format

This is a quick tool for choosing color values in Graphics 2.0 format. The values are arrayed from 0 to 1. Each of the three sliders controls a color, and there is one to control the alpha as desired. The goal of the tool is to grab some color values to use in your projects as you need. Hope it helps! Let me know if something needs to be fixed. Kiffin Ayers More...

Posted by Bead Pond, Posted on 26 Nov 2013, Last updated 26 Nov 2013 | 1 comments

Magnet: Position Helper for Corona SDK Graphics 2.0

A module to position display objects on different screen resolutions. This helper will only work with the newest version of Corona (aka 2.0). Anchors and screen orientations are internally managed to provide consistency. Example: 1 2 local c = display.newCircle(0, 0, 10) -- inside currentStage or currentView magnet:bottomRight(c, 20, 10) -- Align to the bottom right edge of the screen effectively.... More...

Posted by Iván Juárez, Posted on 25 Nov 2013, Last updated 25 Nov 2013 | 0 comments

Cyan - Table Serialization Made Awesome

Being easier to write than normal Lua syntax, just as fast as JSON, and very human-readable, Cyan is the most flexible table serialization notation, ever. It comes in a single code file and uses two function calls to decode/encode Cyan notation or tables. You can find notation documentation at the GitHub page. When creating a Cyan file, kindly include an extension of .cy, because someday I have hopes to create... More...

Posted by Caleb P, Posted on 16 Nov 2013, Last updated 16 Nov 2013 | 1 comments

EventConsole 1.2

EventConsole by mobile8 (original here: http://developer.coronalabs.com/code/eventconsole) updated to work with Graphics 2.0 This is a handy library for on device testing. It creates a small button at the top of the screen that when touched, will show you debug information you've printed to the object. Primary changes were adjusting colors to be 0-1 versus 0-255, the establishment of anchor points versus reference... More...

Posted by marble68, Posted on 12 Nov 2013, Last updated 12 Nov 2013 | 1 comments

PinchZoom with Pan also

I needed to use simple pan in a huge map. I took the PinchZoom example from Interface from Corona. This is the simple example using DragMe together with pinchZoom. Notice that I have a huge image around 3000 x 3000 px. Then it makes sense to use dragme to drag the picture around and then zoom in and out for better view. I also added comments to use swipe and then transition.to to move the map. It was not how I... More...

Posted by miko0, Posted on 7 Nov 2013, Last updated 7 Nov 2013 | 0 comments

Create dynamic text with strokes, drop shadow, rotation, resizing. Interface is as simple as working with a display object.

local Text = {} --[[------------------------------------------------------------ -- Text.draw ---------------------------------------------------------------- -- returns a proxy object that allows you to change text OPTIONS: text => text to draw font => font name fontSize shadow => boolean turns on/off dropshadow (default true) stroke => boolean turns on/off stroke... More...

Posted by benchow, Posted on 29 Oct 2013, Last updated 29 Oct 2013 | 1 comments

Equalizer type of bars

A simple bar graph I used in one of my apps. Just stick the code into a main.lua file and run it. This is an early version but works. Enjoy! 1 2 3 4 5 6 7 8 9 10 11 local widget = require( "widget" ); _W, _H = display.viewableContentWidth, display.viewableContentHeight; display.setDefault( "background", 255, 255, 255 );   local function newBars(dobars, w, h, segcolor, x,... More...

Posted by lessmsios, Posted on 15 Oct 2013, Last updated 15 Oct 2013 | 1 comments

Image Cropper

I was looking for a simple image cropper, and found it in the forums. Thought it would be a good idea to post it here too, as it is very helpful. Inputs : 1) Image object (or could be other objects) 2) width of final object (crop) 3) height of final object (crop) Modification done : - Does not create any additional file - Returns the image object directly. Taken from : http://forums.coronalabs.com/topic/38773-how-to... More...

Posted by yosu, Posted on 14 Oct 2013, Last updated 14 Oct 2013 | 1 comments

Converting to upper case with accented characters

Using string.upper doesn't convert accented letters. If you need to convert a string with accented letters you can use these lines of code. There's certainly a smarter way using regular expressions but my finction is very easy to understand. Hope it will help somebody ---------- local minusChars={"à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","... More...

Posted by jch_apple, Posted on 14 Oct 2013, Last updated 14 Oct 2013 | 0 comments

Multiplayer Game Development using AppWarp Cloud

Corona Color Move Walkthrough We will walk through the integration of AppWarp Lua SDK with a simple Corona application which allows user to move objects in realtime across multiple client. Project Setup and Running Follow these steps and get your key pair and a room id - http://appwarp.shephertz.com/game-development-center/Using-AppHQ Download the color move sample code from our git repo - https://github.com/... More...

Posted by dhruv.chopra, Posted on 8 Oct 2013, Last updated 8 Oct 2013 | 1 comments

Icon Generation

Judging by a couple of pages I've seen recently such as... http://forums.coronalabs.com/topic/39301-new-app-icons-for-ios7/ http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/4434185-auto-generate-app-icons-for-android-ios ...it seems I'm not the only one fed up of making icons. I recently made a script to do it for me. 1. Download and install ImageMagick (http://www.... More...

Posted by spideri, Posted on 1 Oct 2013, Last updated 1 Oct 2013 | 1 comments

Display Multiline (multi line) Text using newText

A simple and fast way to display a long text into several lines of text (using the 'newText' function with align feature). Code is still ugly as more testing is being done. Please let me know if there are any bugs. Concept was taken from Satheesh (http://developer.coronalabs.com/code/useful-multiline-text-library), but tried to improve on it with faster processing. Notes : If the text has "/n", it will break into a... More...

Posted by yosu, Posted on 26 Sep 2013, Last updated 26 Sep 2013 | 1 comments

Parental Gate

Implements Parental Gate functionality for Corona apps that want to be included in the App Store's KIDS section. It does this by showing a required age authorization dialog on startup that cannot be bypassed. Once the age has been selected it is persisted and the user will never be asked to answer the question again. The app can then use the age selected to show or hide various UI elements to conform to Apple’s... More...

Posted by funkyvisions, Posted on 25 Sep 2013, Last updated 25 Sep 2013 | 0 comments

Where's My Water style water

Video: http://screencast.com/t/ccDIzbjPSCNc While trying to make a water simulation I decided that water trails were the best way to go, for now, until Gfx2.0. So this uses a series of circle bodies in the physics engine and trails each with a tail of smaller circles. Each body is significantly smaller than the main body, giving the water a squishy effect. There are control buttons near the top for resetting (red,... More...

Posted by horacebury, Posted on 15 Sep 2013, Last updated 15 Sep 2013 | 1 comments

EndlessScroller

Corona SDK example showing how to create and endless scroller type game. It does this by splitting up a spritesheet into multiple segments and scrolling them from right to left. As an old segment moves off the screen a new segment is created on the right. See the video at: http://youtu.be/UZjt6b4k7Io More...

Posted by funkyvisions, Posted on 9 Sep 2013, Last updated 9 Sep 2013 | 1 comments

Heartbeat

Corona SDK example showing how to use a beating heart as a life meter. Also shows how to change the pitch of a backing track and keep the animation in synch with it. If you want to learn more about bitmaps masks this is a good example. See the video at: http://youtu.be/EZD8wJNCAxc More...

Posted by funkyvisions, Posted on 9 Sep 2013, Last updated 9 Sep 2013 | 0 comments

Scene Navigator

Scene navigator is an attempt to duplicate the behaviour of UINavigationController on iOS. You can push a scene to the navigation stack, then you can just pop a scene, not worrying where you should go back to. Some examples: storyboard.pushScene ( "game" ) then in the game: storyboard.popScene () brings you back to your previous scene. More...

Posted by kender, Posted on 6 Sep 2013, Last updated 6 Sep 2013 | 0 comments

Box2D Water Buoyancy

Demo video: http://screencast.com/t/tA27TbNaY Buoyancy demo providing an enclosed box in which new boxes can be drawn to drop them into the water. In this the water is implemented by a collection of physics sensors all applying force against the objects which collide with them. To fine tune for your application you should play with the number of sensors, force applied, density of the objects dropped into the water... More...

Posted by horacebury, Posted on 14 Aug 2013, Last updated 14 Aug 2013 | 1 comments

EvalExpression - "eval" for math

This is a quick-and-dirty "eval" function that takes a string of math and calculates the result. Since Corona doesn't allow loadstring, you can't otherwise go from math-string to numeric result in your code. The evalMath function assumes the string is just numbers, operands, parens, and standard functions (not all of which are in there yet). The evalString function allows you to send it a table with key=value pairs... More...

Posted by jbp1, Posted on 12 Aug 2013, Last updated 12 Aug 2013 | 0 comments

Convenient object removal

Situation: You have a storyboard scene which spawns display objects which can be removed at any time. You also have tables which can contain references to those objects at any time, for example: sensors which detect physics bodies moving in and out of them. Problem: It is difficult to make sure that your regular tables have those display objects removed from them when the display objects are removed from the scene... More...

Posted by horacebury, Posted on 11 Aug 2013, Last updated 11 Aug 2013 | 1 comments

Cancel multiple timers

To cancel a collection of timers usually means checking the timer value is not nil and calling timer.cancel for each timer. This will do both and allow you to cancel any number of timers. Just remember to nil your own ID variables afterwards. main.lua: 1 2 3 4 local a, b = timer.performWithDelay(1000,someFuncA,0), timer.performWithDelay(2000,someFuncB,0) -- some other code timer.cancel( a, b... More...

Posted by horacebury, Posted on 8 Aug 2013, Last updated 11 Aug 2013 | 0 comments

eliteMath

Lib for intersection Line-Line, Line-Circle, Line-Square. CMathExt.lua: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 module(..., package.seeall);   function new()         local CMathExt = display.newGroup();                 function CMathExt:InterLineLine(p1, p2, p3, p4)              ... More...

Posted by efgames.net, Posted on 6 Aug 2013, Last updated 6 Aug 2013 | 1 comments

Perfect vertical text alignment across devices

By measuring the total font height and where the actual text is visible from top and bottom you can get the percentage offset required to get perfect placement. Because its different on simulator, Android and iOS you need to do this at least 3 times. From what I'm seeing the offset stays consistent across devices within a platform. Thus you only need to do this once for each platform. More...

Posted by jonjonsson, Posted on 4 Aug 2013, Last updated 4 Aug 2013 | 0 comments

Appkeyz

This SDK is designed to allow a developer to easily add either the AppKeyz API by itself, or a suite also containing a "drop-in" authentication module. This repository is a sample app that demonstrates all API calls as well as the authentication. Authentication module works on Android and iPhone Devices in either landscape or potrait. The AppKeyz SDK requires Corona. More...

Posted by mdavis, Posted on 31 Jul 2013, Last updated 31 Jul 2013 | 0 comments

AppKeyz SDK

Free Login / Registration and account management as a service. Know your users and manager your products on your web based dashboard. Once your users and products are managed in our cloud you can aquire users and sell products on your own branded web page and facebook application. Make money in the outside of crowded app stores with AppKeyz. www.AppKeyz.com More...

Posted by mdavis, Posted on 30 Jul 2013, Last updated 30 Jul 2013 | 1 comments

Barspective

The Barspective App is an app that allows users to see into a bar from their phone. This app is a video streaming app that is hopefully going to work here and that i will be able to make it all happen here and now. Apparently I don't know how many words are fifty More...

Posted by admin971, Posted on 25 Jul 2013, Last updated 25 Jul 2013 | 0 comments

ICS style menu

I was looking for a menu that had the ICS style and was easy to use. I couldn't find anything so I decided to create one. The menu will be placed in the top right and will expand / contract to fit the text length. If there are too many items in the menu it will utilize a scroll view so you can scroll through the menu. If the user clicks on the menu item the function passed to it will get called. If the user clicks... More...

Posted by dmglakewood, Posted on 22 Jul 2013, Last updated 22 Jul 2013 | 1 comments

scroll.lua

scroll.lua is a Corona™ class created to control a continuous scrolling background. You can easily create a scrolling background, just add the images, and tell it the speed and direction and the tell it to start its that easy Features: Easy API Use one image or multiple images Control direction, speed, tint, start, stop, show, & hide Control multiple backgrounds at the same time http://j-strahan.com/main/?p=127... More...

Posted by jstrahan, Posted on 16 Jul 2013, Last updated 16 Jul 2013 | 1 comments

hiScore.lua

With hiScore you no longer have to worry about code to handle keeping track of high scores. This Corona Lua Class will save coding time that’s required to keep track of high score list in your game. hiScore v2.0 has added several useful benefits like displaying the list for you, saving & loading to file, & encrypting the file for security. hiScore v2.1 added support for openSSL hiScore v2.2 insert into group... More...

Posted by jstrahan, Posted on 16 Jul 2013, Last updated 29 Jul 2013 | 1 comments

keyboardInput

Overview Trying to test your game in the simulator but find it difficult to control having to use the mouse to tap on buttons. With keyboardInput you can now assign keyboard keys to respond as if you were tapping the buttons with your finger in the simulator. Q & A Q. What can i control with this? A. Any button that uses the ‘tap’ event can use this with no modifications. Q. What about numTaps, does it... More...

Posted by jstrahan, Posted on 16 Jul 2013, Last updated 16 Jul 2013 | 0 comments

More Advanced Print Statement

I dislike the print statement and I prefer to turn off all printing of text before I build an app. Below is a custom function that I call that outputs what I want to print and also allows me to add memory information to the end of the printed text as a certain position (162 chars). Printing cal be disabled by setting "_G.ShowDebug = false" in "main.lua". Adding memory info on the end of each printed line can be... More...

Posted by FearTec, Posted on 7 Jul 2013, Last updated 7 Jul 2013 | 0 comments

State Machine

Hello, this is a state control utility build by LUA coroutine statemachine.lua 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 --[[     statemachine.lua     Copyright (c) 2013 Erin Lin     erinylin.blogspot.com     Licensed under the MIT license.       Usage:     local sm = require("statemachine")       local process = sm... More...

Posted by Erin, Posted on 6 Jul 2013, Last updated 6 Jul 2013 | 1 comments

Runtime bitmap maskfile creation

I have been looking for ways to address the mask file needs vis a vis many Android device resolutions. I tried a number of dynamic mask file creation options but none of them met all of my needs. Finally I came across the following Code Exchange post by James03 posted back in Feb '13. Thanks James!!! Your post gave me a great jumping board. : http://developer.coronalabs.com/code/super-simple-and-freakishly-fast-... More...

Posted by ksan, Posted on 5 Jul 2013, Last updated 5 Jul 2013 | 1 comments

Corona Styled Textwrap

corona-styled-textwrap ====================== A pure-Lua text rendering module for Corona SDK which can handle basic HTML, fonts, and even basic font metrics. I've made this library public in the hopes that we can fix the bugs and improve it. The documentation is poor, I know...feel free to help, or ask me questions!!! It has a major flaw right now -- it messes up trying to render styled text that is right/center... More...

Posted by mimetic, Posted on 1 Jul 2013, Last updated 1 Jul 2013 | 1 comments

App Utilities

Building utility apps, as opposed to games, can run into some problems with Corona. This library is to overcome some of those issues. This list will grow. The functions included at present are: -- auto-addition of a .sceneName property to storyboard scene objects -- nearest multiple function for avoiding the "nearest multiple of 4" warning with display.newText() -- replacement display.newText() function to implement... More...

Posted by horacebury, Posted on 22 Jun 2013, Last updated 22 Jun 2013 | 1 comments

Custom display.setDefault

The display.setDefault function is useful if you want to define a default value for various API operations. It is not completely inclusive however. For example, you cannot set a default line width for the display.newLine function. The code below shows how to provide your own function to be called when a CoronaSDK display function is called, so that you can implement your own overriding defaults. The example used is... More...

Posted by horacebury, Posted on 20 Jun 2013, Last updated 20 Jun 2013 | 1 comments

Mixpanel

API for sending events to Mixpanel on Corona SDK Currently implements the track and superProperties APIs Just call initMixpanel with your Mixpanel token and then track relevant events. Code is open, and pull requests are accepted and appreciated. 1 2 3 4 5 local mixpanel = require 'mixpanel' mixpanel.initMixpanel(MIXPANEL_API) mixpanel.track( 'clickedAd', {   ['Banner Color'] = 'Blue... More...

Posted by jeduan, Posted on 19 Jun 2013, Last updated 19 Jun 2013 | 0 comments

Animation Chain

Wraps transition.to calls up to allow jQuery style function chains such as: 1 animationchain.anim(obj,options).whenDone(obj2,options).onStart(obj3,options).start() I wrote this to avoid confusing callback hell. Feel free to expand, optimise or correct this! I've not tested the performance, but I expect it to be somewhat worse, however my focus was on code structure, not speed. For up... More...

Posted by tap32, Posted on 18 Jun 2013, Last updated 18 Jun 2013 | 0 comments

fontBOX - Finally a way to format text!

Version 1.1 Corona's options for formating text are pretty poor. So I wrote a module that solves this problem. With this module you can create text fields, which offer you several formating options. These are: - Manual line breaks - Manual line height - Left justified, right justified or centered text alignment - Individual passages can be recolored, resized or underlined - Write the entire text in uppercases More...

Posted by torbenratzlaff, Posted on 6 Jun 2013, Last updated 12 Jun 2013 | 1 comments

Easy way to pass arguments to an event handler

Hi, A ugly way to pass arguments to an event handler is doing this: 1 2 3 4 5 6 7 8 9 10 function printVars(event, var1, var2)     if event.phase == "ended" then         print(var1)         print(var2)     end end   local button = display.newRect(0, 0, 100, 30)   button:addEventListener( 'touch',... More...

Posted by emi, Posted on 5 Jun 2013, Last updated 5 Jun 2013 | 0 comments

Color picker

Hello. I implemented this since I'll be needing it here and there in an editor. It was mostly puzzled out by looking at a couple of others and realizing what they must be doing (elaborated a bit in the comments). Went down some major rabbit holes, but it's about where I want it now, apart from customization. 1 2 3 4 5 6 7 --- Color picker UI element. -- -- @todo Document skin...   -- -- Permission is hereby... More...

Posted by StarCrunch, Posted on 24 May 2013, Last updated 24 May 2013 | 1 comments

Predictive Aiming / Tower Defense

Here is a physics and a non-physics sample for predictive aiming, auto-targetting or the classic "tower defense" solution. The first sample requires you to tap to add towers. Regular Box2D sensor collision detection is used in the second sample to begin firing at a target. Please note that targets which cannot be hit will not be fired at - this is much more common and more misleading than common sense would indicate... More...

Posted by horacebury, Posted on 22 May 2013, Last updated 22 May 2013 | 1 comments

VIVE

VIVE Versatile Independent Variable Encoder (rhymes with "hive") An easy, reliable, and flexible way to convert tables to strings and vice-versa. Supports keys of type "string" or "number" Supports values of type "string", "number", "boolean", or "table". What is VIVE? More...

Posted by Caleb P, Posted on 21 May 2013, Last updated 21 May 2013 | 1 comments

Ball of light on a sphere

Hi. This is something I was playing around with (in part because I was without an Internet connection for a while...). It's a self-contained version of the linked Github snippet (which is probably subject to change... I think some other ideas might better fit the "pixels" idea). Basically, there's a ball of light roving around a sphere. There's some lighting calculations going on, according to where the ball is, and... More...

Posted by StarCrunch, Posted on 17 May 2013, Last updated 17 May 2013 | 0 comments

Remote Events

"Remote Events" is a small package we developed for debugging accelerometer events. It includes two main modules: 1. Client app you can compile for iOS or Android and run from your device 2. Server module which you "require" in your project main lua which is ran on the Corona Simulator. You will need to add the file "remoteEvents.lua" to your project root path. Once you add the module to your project add the... More...

Posted by gtt, Posted on 5 May 2013, Last updated 5 May 2013 | 1 comments

Mario Style "Star" Effect

This will make an effect where your screen will flash through random colours like when you have a Star in Mario. The effect will cover the entire screen and it's self contained in a single lua file. All cleanup will automatically be done after the animation is finished (or if you end it early by calling stop() - see below for more details) Require the module:  local rainbowScreen = require("... More...

Posted by naveen_pcs, Posted on 20 Apr 2013, Last updated 20 Apr 2013 | 1 comments

Easy setFillColor Transition

Here're 2 small self-contained functions you can use to perform a smooth transition for fillcolors: Usage: Initially set a fill color via: (We need this so that we can know what the color to transition FROM is) 1 2 local g = display.newRect(0, 0, 100, 100) setFillColor(78, 186, 248) Then just call the set fill color transition via: 1 2 -- sets the color of 'g' to {255, 128, 0} for 3000 milliseconds... More...

Posted by bfintal, Posted on 16 Apr 2013, Last updated 16 Apr 2013 | 1 comments

Convert RGB to HSB/HSV

If you want to convert HSB to RGB, look at my snippet here https://developer.coronalabs.com/code/convert-hsbhsv-rgb Now, I needed to convert a RGB value back to HSB, so here it is: 1 2 3 4 5 6 7 8 9 10 11 function  rgb2hsb (rR, gG, bB)         local r, g, b = rR/255.0, gG/255.0, bB/255.0         local h,s,v = 0,0,0         local hsbColorTable... More...

Posted by canupa.com, Posted on 14 Apr 2013, Last updated 14 Apr 2013 | 0 comments

Calendar Sample

Hi! This is a simple calendar sample to implement in your storyboard app. I couldn't find any calendars when I searched the forum so I made this myself. It's pretty straight forward, everything is in the calendar.lua. Features: - Displays current month and all of its days. - Change months To-do-list: - Add an event to a day - SQL-integration - Theme selection (change of colors) - Slide to change months I'm still... More...

Posted by joelwe, Posted on 12 Apr 2013, Last updated 13 Apr 2013 | 1 comments

AES using http://crypto-js.googlecode.com

Uses JS from http://crypto-js.googlecode.com to build a AES value... Change "Secret Text" to what you want to encrypt. --[[]] local function webListener( event ) URLA = event.url if event.url then print( "You are visiting: " .. event.url ) if string.find ( URLA, "url:" ) ~= nil then native.showAlert( "AES:", string.sub(event.url,5,string.len(event.url)) , { "OK" } ) print ( string.sub(event... More...

Posted by Minion Multimiedia, Posted on 5 Apr 2013, Last updated 5 Apr 2013 | 1 comments

Daily bonus

A five-day cycle for daily bonus You'll be needing this preference library: http://developer.coronalabs.com/code/save-data-files-tablesnumbersstringsboolean 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 prefs = require "preference_library"           local function checkForSinglePlayerBonus( )                   local lastDayNum = prefs.... More...

Posted by paskuniak, Posted on 2 Apr 2013, Last updated 2 Apr 2013 | 1 comments

Structuring your display objects and their transitions/timers for easy removal

When building a display object, structure the timers and transitions under it. So, when it comes time to destroy the object, any timers and transitions you've used regarding it will be properly canceled, preventing any memory leaks or crashes due to unresolved tweens. With the two functions below, you can destroy a single object, an object in an array, or an entire array of objects. 1 2 3 4 5 6 7 8 local function... More...

Posted by BeyondtheTech, Posted on 1 Apr 2013, Last updated 1 Apr 2013 | 1 comments

Sweeping through a table of display objects

Perhaps some of you know this already, but it wouldn't hurt to post, since it can help bring everyone up to speed. Let's say you create a table of display objects, like gems, or missiles or enemy ships, and you want to sweep through the entire table to do something with them, like making them all explode or disappear instantly. More...

Posted by BeyondtheTech, Posted on 25 Mar 2013, Last updated 25 Mar 2013 | 1 comments

CBResources

CBResources complements CBEffects, containing valuable resources like samples, tutorials, the most recent versions of CBGadgets, and more. CBResources has now been melded into the CBEffects GitHub repository, so you can download it there. Contribute to it's development, aid in the creation of the wiki, report bugs, or just download CBEffects to use at the GitHub page. Enjoy! Caleb More...

Posted by Caleb P, Posted on 20 Mar 2013, Last updated 17 Aug 2013 | 1 comments

Doug Lapsley

Maybe something that others have already done, but a small amend to spriteGrabber to enable sub folders to reference the png if the sprites are in a sub folder. --SpriteGrabber Version 1.2 December 12, 2010 At line 195 replace: local iSpriteSheet = sprite.newSpriteSheetFromData( sheetName..sheetExtension, sData ) with local iSpriteSheet = sprite.newSpriteSheetFromData( string.gsub(sheetName,... More...

Posted by doug.lapsley, Posted on 18 Mar 2013, Last updated 18 Mar 2013 | 1 comments

Basic LinkedIn Integration

This is adapted from the Corona Twitter sample code project. So far this will simply allow a user to log in and post a "share" to their stream (LinkedIn shares are essentially the same as Facebook status updates, or Tweets). You will first need to setup a LinkedIn app (http://developer.linkedin.com) and then enter the API Key and Secret Key from there to the top of the LinkedIn.lua file. The "doPostUpdate" function... More...

Posted by AlanPlantPot, Posted on 17 Mar 2013, Last updated 17 Mar 2013 | 0 comments

GridView for Corona SDK

This UI is used to show a GridView on the screen, which is sort of a photo album. It could show the figure as buttons, and labels on each figures. In addition, the label length is adjusted when the string length is longer than the figure width. You can control the GridView position, and how many columns are shown in each row. Go ahead to apply this library in your project. Only few line, you can show the GridView... More...

Posted by shihhsin, Posted on 17 Mar 2013, Last updated 17 Mar 2013 | 1 comments

Switch physics display mode on device

If you want to switch between normal and hybrid physics mode on your device using a shake is a good way to do this without needing to use an on-screen button, which would need to be taken out later... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 -- switches physics mode easily on device local hybridon = true function jerk(e)         if (e.isShake) then          ... More...

Posted by horacebury, Posted on 13 Mar 2013, Last updated 13 Mar 2013 | 1 comments

Simple particle gravity with path plotting

This is a slightly modified version of the "Simple particle gravity" code which only uses one particle but plots the course the particle will take. Tap to add gravity points. Swipe to add lots of particles. Video: http://screencast.com/t/tJ0g5SdwA main: 1 2 3 -- simple particle gravity - path prediction   --http://board.flashkit.com/board/showthread.php?629375-HELP-2D-gravity-simulator-multiple-mass-points More...

Posted by horacebury, Posted on 12 Mar 2013, Last updated 12 Mar 2013 | 0 comments

Simple particle gravity

This is a particle gravity demo that I converted from a flash forum post. It's pretty straightforward and open to a lot of fiddling. Requires no supporting library. Swipe to create particles, tap to create gravity wells. Video: http://screencast.com/t/NKnifkMcYb main.lua: 1 2 3 -- simple particle gravity   --http://board.flashkit.com/board/showthread.php?629375-HELP-2D-gravity-simulator-multiple-mass-points More...

Posted by horacebury, Posted on 11 Mar 2013, Last updated 11 Mar 2013 | 0 comments

loadSoundLibrary: a quick way of structuring and loading your sound effects

If your code (and your build files) are getting a little discombobulated with all the sound effect files you have to load, this little code snippet can make loading sounds a lot easier with a lot less code. As your development progresses, many of you might notice a growing list of sound files sitting in the same folder as your image files as well as your lua code, so having a long directory could get a little messy... More...

Posted by BeyondtheTech, Posted on 8 Mar 2013, Last updated 8 Mar 2013 | 0 comments

Stackbuster: a Jawbreaker clone

I was asked to create a game like Jawbreaker from Windows, Windows Mobile and other devices. Here it is in its full glory. Does not need or use any assets, as everything is drawn using Corona's own graphics APIs. 1 2 3 4 5 6 7 8 9 10 ----------------------------------------------------------------------------------------- -- -- stackbuster.lua -- created by Raphael Salgado as BeyondtheTech -- version 1.0 -... More...

Posted by BeyondtheTech, Posted on 7 Mar 2013, Last updated 7 Mar 2013 | 1 comments

Batch convert AIFF/MP3/WAV files to CAF

If you're working with another party that tends to hand you audio files in another format, but you need it in CAF format for use with iOS devices (IMA 4:1 compression provides the smallest files possible, which is great for constrained memory limits on mobile devices), use this bash script in Mac OS X. Simply copy it to the same folder as the compatible audio files (must be .AIFF, .MP3, and/or .WAV), and run it in... More...

Posted by BeyondtheTech, Posted on 7 Mar 2013, Last updated 7 Mar 2013 | 0 comments

Calculate Area of a Polygon

This is a straight forward conversion of the code found here: http://www.mathopenref.com/coordpolygonarea2.html Be aware that it will not calculate the area of polygons which which intersecting vertices - that is, if the polygon is twisted so that its lines cross over, it will not work properly. main.lua: 1 2 3 4 -- polygon area   stage = display.getCurrentStage() sWidth, sHeight = display.contentWidth... More...

Posted by horacebury, Posted on 5 Mar 2013, Last updated 5 Mar 2013 | 0 comments

Sidebar UI example

This is a quick and nasty demo of a sidebar UI like Facebook. This code was done quickly just to show the basic concept and not to be used in production. The idea is for people to understand the concept and expand on it, creating their own version with better/more finalized code. I have seen comments in the forums on if this was possible so here is just a small demo with some code to show that it is possible.... More...

Posted by chevol, Posted on 2 Mar 2013, Last updated 2 Mar 2013 | 1 comments

Twitter fix for HTTPS

Twitter with oAuth recently stopped to work, because twitter no longer accepts non secure requests. I've modified oAuth module to support HTTPS. Basically replaced http.request with network.request. Thus added async networking. Also I've cleaned those examples to look better. So now it's more visual and you can add new api calls in it easily. I've added two new methods - getFollowers() - gets a list of your... More...

Posted by Lerg, Posted on 2 Mar 2013, Last updated 2 Mar 2013 | 1 comments

text align right ( working ! )

This is a modified version of the newretinatext function from the beebegames-class ( http://developer.coronalabs.com/code/beebegames-class ). It aligns every font in every size without gaps, leaps... to the right. The original class wasn't working properly for me. but it brought me on the right track. see for yourself. 1 2 3 4 5 6 function newRetinaText( textString, x, y, fontName, fontSize, r, g, b,... More...

Posted by searchm, Posted on 28 Feb 2013, Last updated 12 Jun 2013 | 1 comments

Polygon Intersection

This code detects where two polygons intersect and produces a third polygon for the intersection area. I have not tried it with particularly complex polygons, but it should be enough for use with Box2D body shapes. Please note that I got this from rosettacode.org and have simply modified it enough to work with Corona and provide a demonstration. main.lua: 1 2 3 4 5 6 7 -- http://rosettacode.org/wiki/Sutherland-... More...

Posted by horacebury, Posted on 26 Feb 2013, Last updated 26 Feb 2013 | 1 comments

Simple Bubble Popper

Bubble Popper for the CoronaSDK This template was constructed to demonstrate many aspects of programming in lua for Corona. It is an updated version of some simple code I posted quite some time ago which helped many users get a start. This new version goes much further with graphics and the intent to show many different techniques that are not quickly identified when starting with Corona. You will learn How to... More...

Posted by TheRealTonyK, Posted on 24 Feb 2013, Last updated 13 Mar 2013 | 11 comments

Barcode Scanning w/Pic2Shop

Shows how to integrate Pic2Shop barcode scanning. (iOS for the time being) build.settings 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 -- cpmgen build.settings settings = {         orientation =         {                 default ="portrait",              ... More...

Posted by Minion Multimiedia, Posted on 19 Feb 2013, Last updated 19 Feb 2013 | 2 comments

Btl - Easy to Use Debugging System - Version 1.1

Overview: Update 1.1 - Added Globals Checker Btl (pronounced "beetle") is a very easy to use debugging system. It can keep track of time, check memory, log entries, or find globals. It's very lightweight and has three draw modes - terminal, visual, or programmatic. In terminal draw mode, all values are printed to the terminal. In visual draw mode, a simple GUI is created with the stats on it - please note that the... More...

Posted by Caleb P, Posted on 16 Feb 2013, Last updated 18 Feb 2013 | 1 comments

Transition Manager

The Transtion Manager was developed for transitions could be paused and resumed Usage example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 local TransitionManager = require 'TranstionManager' local isPaused = false   local transitionManager = TransitionManager.new()   local circle = display.newCircle(100,100, 40) local rect = display.newRect(10,10, 40, 40)   local function... More...

Posted by stephannvasconcelos, Posted on 15 Feb 2013, Last updated 15 Feb 2013 | 3 comments

User rating by a 5-star view library

Because Corona SDK has not supported the rating view, I create a library named starView to do that job. It is quite simple to apply this library in three lines. First, we include the starView library in the program. 1         local starsView = require("starsView") Then, we initialize the starView object. The parameters are the x, y, initial star numbers, and is editable of the... More...

Posted by shihhsin, Posted on 14 Feb 2013, Last updated 14 Feb 2013 | 2 comments

Jumping pony game

Jumping pony game is demo project for lutsk.io meetup. App use physics engine and touch events to move pony left or right. Gravitation move pony bottom and it bounces from the grass. It is a very easy example, targeted for the begginer Corona SDK developers. Total code lines is about 20. Video on Youtube Enjoy! More...

Posted by vova.sergeyev, Posted on 8 Feb 2013, Last updated 8 Feb 2013 | 0 comments

Sol Control RTS game

Space real-time strategy. We have spent about a year working on it and it looks like long-time-never-published project. So we pushed it to open source :) At first game was create primarily for iPad device. But as it use Corona SDK framework, so can be compiled to Android, Nook, Kindle devices as well. Sample videos Game is fully functional, Enjoy! More...

Posted by vova.sergeyev, Posted on 8 Feb 2013, Last updated 8 Feb 2013 | 1 comments

Convert HSB/HSV to RGB

See http://en.wikipedia.org/wiki/HSV_color_space for more info Original source: http://www.docjar.com/html/api/java/awt/Color.java.html "This function converts the components of a color, as specified by the HSB/HSV model, to an equivalent set of values for the default RGB model." 1 2 3 4 5 6 7 8 9 10 11 12 13 function    hsv2rgb    (h, s, v)         local r,g,b... More...

Posted by canupa.com, Posted on 5 Feb 2013, Last updated 14 Apr 2013 | 1 comments

Thumbprint Scanner

This project I created for several reason and I’m pleased to share it with all of you. If anyone has used my Corona Shell Project (A starting point for any project) based on Director 1.4 you know how handy it is to get a jump start on a new project when you already have some plumbing in place. I created this Thumb Scanner as a fun aspect to “secure” scenes from users until they put in the proper code and “scan”... More...

Posted by croisened, Posted on 4 Feb 2013, Last updated 4 Feb 2013 | 0 comments

Super Simple and Freakishly Fast Bitmap mask creation for ScrollView using ImageMagick

So you want a scrollView that only takes up some of the screen? You'll need a bitmap mask, which is pretty easy to create using your favourite GUI tool but not that quick and if you don't have or know your way around photoshop or GIMP somewhat daunting. But if you have ImageMagick installed you can do it in one line from the command line: For a scrollView W x H: 1 convert -size W+4xH+4 xc:black -fill white -draw... More...

Posted by james03, Posted on 4 Feb 2013, Last updated 4 Feb 2013 | 0 comments

DMC Lib - Auto Store

dmc_autostore is a Lua module which makes saving application and game data painlessly easy, because it uses NO API ! At the start you are given an empty Lua table. You add and remove data as you need. Any modifications which you make anywhere in the data structure will save your changes to JSON. Super simple? Yes ! Super awesome? Definitely !! Features A great fit with object-oriented programming More...

Posted by dmccuskey, Posted on 1 Feb 2013, Last updated 10 Feb 2013 | 2 comments

Corona Tiled

Loads JSON saved map files from Tiled http://www.mapeditor.org/ Author: Michael Wilson / NO2 Games, Inc. - www.no2games.com More updates in v0.4 SUPPORTED JSON or LUA exported map files Multiple Layers Multiple Tilesets Custom Tile shapes Finding Objects by name Setting Physics properties from the map editor Object types (regular, polygon, line) that support physics properties Uses Corona Image Maps and Image Map... More...

Posted by no2games, Posted on 31 Jan 2013, Last updated 9 Apr 2013 | 1 comments

Force Object Pass-Through

Lets say you have a ball and a wall. You want the ball to pass through the wall, but only if the ball hits the wall with a low enough force (or high enough - whatever threshold.) Problem: Box2D only provides the "event.force" value in the "postCollision" event. This means that you can only measure the amount of force the ball hit the wall with once the ball has bounced off the wall and is travelling away from it.... More...

Posted by horacebury, Posted on 25 Jan 2013, Last updated 25 Jan 2013 | 0 comments

NeonPong - Complete Pong Sample Game/Template

I made a complete version of Pong for a demo/sample code example. I commented all of the code (heavily) and it wasn't all that complicated in the first place, so there should be no trouble with understanding it :) There is a CPU, different difficulties, (easy, medium, hard, and endless), and it does collision checking and moving of the ball without physics. It's also quite fun ;) More...

Posted by Caleb P, Posted on 17 Jan 2013, Last updated 30 Jan 2013 | 4 comments

Google Connect

Google Connect is a simple module for connecting with google APIs via OAUTH2 The module also persists the user's refresh token so the he only needs to log in and authorise the app once. Example usage: 1 2 3 4 5 6 7 8 9 10 11 local gConnect = require("googleConnect")   function connectCallback(event)         if(not event.isError) then      ... More...

Posted by contato00, Posted on 14 Jan 2013, Last updated 14 Jan 2013 | 4 comments

Krooshal: In-App Update Framework

Krooshal for Corona is a super-simple SDK to keep your Corona apps updated. You integrate it during development and when deployed on device, ensures your testers and users are running the latest version. When you release a new version, simply set the update to mandatory/optional on krooshal.com and users will be alerted next time they open up the app. More...

Posted by krshl, Posted on 14 Jan 2013, Last updated 31 Jan 2013 | 0 comments

Useful MULTILINE TEXT Library

WARNING : UGLY CODE AHEAD This library can be used to create multiline texts.. How this differs from the in-built multiline text feature is, EACH LINE OF THE MULTILINE TEXT WILL BE A SEPARATE TEXT OBJECT ITSELF . Although each line is a separate display object,the function returns a single display object group so you can manipulate the single display object group. You can access the individual text objects as well... More...

Posted by Satheesh, Posted on 8 Jan 2013, Last updated 20 Jan 2013 | 2 comments

Chains

Demo: http://www.screencast.com/t/LWElsGoCfzyc Since the ragdoll sample was included in the Corona samples directory to demonstrate the setContinuous function, I've wondered about other uses. The code below allows the user to draw a chain and have it fall onto a collection of obstacles. This was previously difficult in Corona because eventually the forces upon the joints would break the chain apart. Use the circle... More...

Posted by horacebury, Posted on 8 Jan 2013, Last updated 8 Jan 2013 | 1 comments

Ouya Support

Easily add OUYA controller support for your Corona SDK games. Check out main.lua to see an example. Check out the video of our game Zombie Dash which uses this class: http://youtu.be/zq8mSTrpmqA. Or download the app for iOS on itunes: https://itunes.apple.com/us/app/the-zombie-dash/id584241591 main.lua 1 2 3 4 5 6 7 8 9 10 11 local function ouyaListener( event )           --add your... More...

Posted by RedPistonEB, Posted on 7 Jan 2013, Last updated 7 Jan 2013 | 8 comments

Idit

Idit is a visual level builder. I create physical levels by creating rectangles with physics and positioning them on top of my level. However, when doing this, a great deal of trial and error goes into it - "Ok, so I'll put it with 150 X. Oops! What about 175 X? Oops! What about 165 X? Ooops!" - etc. More...

Posted by Caleb P, Posted on 7 Jan 2013, Last updated 30 Jan 2013 | 1 comments

Paginated ScrollView widget

I was in need of paginated ScrollView - and the "page" width should be allowed to be lesser then the screen width. So I came up with this very simple modification of the standard widget: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15   local widget = require ( "widget" )   function newScrollView ( params )         local sc = {}         if... More...

Posted by kender, Posted on 3 Jan 2013, Last updated 3 Jan 2013 | 1 comments

ladder game

Please help me.Ladder game object, which creates a ladder, do not go ..Unfinished source code I created to raise.Complementary to, please let us know.Completion to give you the help. AskStart has been recently dropped really hard for me .. TT display.setStatusBar( display.HiddenStatusBar ) local bg = display.newImage("black.png") local textObject = display.newText("1 2 3 4 5 6 7 8 9 10",6,10,nul,20) textObject:... More...

Posted by 78webmst, Posted on 1 Jan 2013, Last updated 1 Jan 2013 | 1 comments

ladder game

Please help me.Ladder game object, which creates a ladder, do not go ..Unfinished source code I created to raise.Complementary to, please let us know.Completion to give you the help. AskStart has been recently dropped really hard for me .. TT display.setStatusBar( display.HiddenStatusBar ) local bg = display.newImage("black.png") local textObject = display.newText("1 2 3 4 5 6 7 8 9 10",6,10,nul,20) textObject:... More...

Posted by 78webmst, Posted on 1 Jan 2013, Last updated 1 Jan 2013 | 2 comments