FusePowered

Calculate Area of a Polygon

Posted by horacebury, Posted on March 5, 2013

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, display.contentHeight

Barcode Scanning w/Pic2Shop

Posted by Minion Multimiedia, Posted on February 19, 2013, Last updated February 20, 2013

GitHub URL: 
https://github.com/comp1400/Barcode-Scanning-with-Corona-SDK-and-Pic2Shop.git

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",
                content = "portrait",
                supported =
                {
                        "portrait"
                },
        },
 
        iphone =
        {
                plist =
                {
                        UIFileSharingEnabled = true,
            CFBundleURLTypes =
            {
                {
                                        CFBundleURLName = "com.SomethingHere.yourapp",
                    CFBundleURLSchemes =
                    {
                        "yourapp",
                    }
                }

Btl - Easy to Use Debugging System - Version 1.1

Posted by Caleb P, Posted on February 16, 2013, Last updated February 18, 2013

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 logging system or the globals system will not work with the visual draw mode. In programmatic draw mode, all of the values are returned.

User rating by a 5-star view library

Posted by shihhsin, Posted on February 15, 2013

GitHub URL: 
https://github.com/worldstar/StarView.git

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 starView. You could see the starView could work well now.

1
        starsView:new(200, 150, 4, true)

Finally, you could get the result by the following code.
 

Convert HSB/HSV to RGB

Posted by canupa.com, Posted on February 5, 2013, Last updated April 14, 2013

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
    local i
    local f,p,q,t
    local colTable = {}
    
    if s == 0 then
        r  = v
        g = v
        b = v
        colTable = {  math.round(r * 255), math.round(g * 255), math.round(b * 255)  }
        return colTable  

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

Posted by james03, Posted on February 5, 2013

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 "rectangle 2,2 W+1,H+1" mask-WxH.png

Example for a scrollview that takes up half the screen in portrait mode, i.e. 320x240:
 

DMC Lib - Auto Store

Posted by dmccuskey, Posted on February 2, 2013, Last updated February 10, 2013

GitHub URL: 
http://github.com/dmccuskey/DMC-Corona-Library

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

Corona Tiled

Posted by no2games, Posted on January 31, 2013, Last updated April 9, 2013

GitHub URL: 
https://github.com/superqix/CoronaTiled

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 groups if you limit yourself to a single tileset image
Setting custom tile/layer/map properties
Margins and spacing

Example

Useful MULTILINE TEXT Library

Posted by Satheesh, Posted on January 8, 2013, Last updated January 21, 2013

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 as shown in the code below.. . Also you can align the multiline text left,right or center.

I found this useful lots of times so sharing this..

Ouya Support

Posted by RedPistonEB, Posted on January 7, 2013

GitHub URL: 
https://github.com/redpiston/CoronaOuyaController

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 button specific code here
 
        --EXAMPLE:
        --if event.buttonName == "o" and event.phase == "pressed" then
        --      player.jump()
        --elseif event.buttonName == "u" and event.phase == "pressed" then
        --      player.punch()
        --end