The engine behind Splitter Flash game – new AS3 prototypes

Splitting Box2D objects seem to be the ultimate challenge around here… after The engine behind Splitter Flash game – first AS3 prototype, now we have two updates… the first by Guillaume Pommey, author of the previous prototype and the second one by Bryce Summer.

While Guillaume wants to refine a bit the final code before publishing it, here it is Bryce work:

Here is my messy attempt at recreating the splitter engine that you posted about on your blog. The code is VERY messy and it doesn’t really work but I decided to send it to you incase it would help at all. The controls are a little funky, you have to move the mouse over to the lower right corner so that the red line is across one of the shapes and click. Sometimes it will (sort of)split it, sometimes it will do nothing. Gravity is disabled at first, hold g to turn it on and release it to turn it off(I added the gravity toggle to try and figure out what was going wrong).

The actionscript resides in two files, one in the timeline and one in the Cutter class

This is the one in the timeline:

And this is Cutter.as

This is the final result:

And this is the source to download

  • New

    function kUpp(e:KeyboardEvent):void
    {
    if (e.charCode == keyToChek.charCodeAt(0))
    {
    m_world.SetGravity(new b2Vec2(0,0));
    }
    }

    Should be kUp and keytoCheck instead kUpp and keyToChek

    It works, like half, when gravity is on, it cuts it mostly properly but the half that is over the red line gets frozen still and only the cutted half falls S:

  • Uchiha

    I was testing some polygon shapes on another project and some of them were always static depending on how the vectors were sorted.
    A triangle with 0 and 1 on the x axis and 3 on the negative y axis didn’t work for me, i.e.
    But if I changed the -y axis to vector [0] it would work.
    It looks very similar to what’s happening with this script.