rgb

Posted by jstrahan, Posted on January 12, 2014

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 = { aliceBlue             = { 0.941176,  0.972549,  1         },
                    antiqueWhite          = { 0.980392,  0.921569,  0.843137  },

Display group indexOf

Posted by horacebury, Posted on January 11, 2014

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
table.indexOf = function( tbl, element )
        if (tbl.numChildren == nil) then
                return _indexof( tbl, element )
        else
                for i=1, tbl.numChildren do
                        if (tbl[i] == element) then

Super colorful print() function

Posted by josellausas, Posted on December 3, 2013

GitHub URL: 
https://github.com/zunware/luaColors

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

Magnet: Position Helper for Corona SDK Graphics 2.0

Posted by Iván Juárez, Posted on November 26, 2013

GitHub URL: 
https://github.com/radixzz/magnet

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. With 20px of margin from the right and 10px from the bottom

*All display objects are aligned relative to the parents. It supports groups, containers and snapshots.

Cyan - Table Serialization Made Awesome

Posted by Caleb P, Posted on November 16, 2013

GitHub URL: 
http://www.github.com/GymbylCoding/Cyan

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 another branch of Cyan that is a mini-language, with variables and such goodies.

Enjoy!
- Caleb

EventConsole 1.2

Posted by marble68, Posted on November 12, 2013

GitHub URL: 
https://github.com/inzi/shared-lua-scripts/blob/master/eventConsole.lua

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 points, and the nuances thereof.

How I use it:

require("eventConsole")
eventConsole = eventConsole:new()

function printConsole (stmp)

Converting to upper case with accented characters

Posted by jch_apple, Posted on October 14, 2013

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={"à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"}
local majusChars={"À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","÷","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß"}

Multiplayer Game Development using AppWarp Cloud

Posted by dhruv.chopra, Posted on October 8, 2013

GitHub URL: 
https://github.com/shephertz/AppWarpLua/

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/shephertz/AppWarpLua/

Icon Generation

Posted by spideri, Posted on October 1, 2013

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.imagemagick.org/) and add it to your path if needed.

2. Create a batch file called for example "build_icons.bat" and include the following text:

 

Scene Navigator

Posted by kender, Posted on September 6, 2013

GitHub URL: 
https://github.com/owlcoding/KendersLib/blob/master/sceneNavigator.lua

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.