Friday, April 11, 2014

Improved Slicing

The previous post showed cutting an object with lines and a curve. I've worked the code and can now slice an image into many pieces.

As before, if you would like this for your own projects, please get in touch on the CoronaLabs forums - user Horacebury.

Friday, March 21, 2014

Polygon Slicing With Corona SDK

As we all know by now, Corona SDK includes the fantastic 2D physics engine Box2D. Play with this for long enough and knowing how to manipulate polygons becomes very useful indeed. I've wanted to implement everything from Angry Birds to iSlash, so it was awesome to see Corona Labs include the new display.newOutline() function in a recent build.

This cool function basically takes a PNG with web transparency and returns a table of x,y coordinates for the circumference polygon of the visible pixels in the PNG. That polygon can then be plugged into a new constructor parameter of the physics.addBody() function to actually create a physics body against an image for that image's outline.

I wanted to take that further, ala iSlash, and decided to produce a library which would take the outline polygon and the end points of a line and separate the polygon into sliced parts. I won't go into the painful details of trying to dig up the code from the internet but suffice to say that code I found was either unintelligable enough to use or simply a mass of maths that I couldn't fathom.

Fast forward a few days and having tried at least 3 different methods I finally hit upon a winner. Here's the proof, running on Mac Corona simulator...

[View full size video]

As you can see, the intersection code works both for a single line cutting straight through the object at any any angle and even re-entering the polygon multiple times. It also handles a hand-drawn curve which, likewise, can start anywhere and enter/exit the shape as often as required. This allows quite a powerful set of options ranging from effects seen in iSlash to cutting shapes into unordered pieces.

I won't be posting the code this time as I fully intend to use this in my own productions. If you would like to implement this in your own production please get in touch via the Corona forums or on twitter: @horacebury

Friday, March 14, 2014

Corona Sample Code And Libraries

Here you can find my most recent Corona SDK samples, demos and libraries. I decided to create a new post because the date on the last one is really quite old and many things have changed in Corona SDK since I started it. You can consider everything here as compatible with Corona since the great Graphics 2.0 update of late 2013.

You can find my Code Exchange posts here:
They are all submitted to github Gists:

Thursday, June 27, 2013

Angry Birds in 30 Mins

It's a bit old now, but the proof still stands and this is a very entertaining video: Seb Lee-Delisle teaching an audience how to code up a simple Angry Birds in 30 mins with CoronaLabs' CoronaSDK.

You can follow Seb on Twitter: and browse his internet wanderings:

Tuesday, January 01, 2013

Sample Code

Bunch of sample codes I've written for use in lua on the Corona SDK, utility and math libraries.
Some of these may appear in both lists due to being a library within a demo.

I have now added a third list of other people's libraries as they are proving quite useful.



Sample/Demo code:


Friday, November 30, 2012

Monday, October 29, 2012

Not A Fan

I'm not a massive Microsoft fan these days, so it's not hard to read these frankly funny reviews of the Microsoft Surface "tablet" (not the table)...
And the follow up being the absolute pounding of Windows/Metro...