Shrink it Box2D prototype

Finally the Shrink it prototype is ready.

Shrink it

This post continues Scaling objects with Box2D and Scaling objects with Box2D – part 2, with these features:

1) You can’t modify static objects

2) You can shrink objects with left mouse button, and expand them with left mouse button + SPACE, as in the original game

3) You can shrink/expand any polygon thanks to Ilya‘s suggestion made in this post.

Now in the stage we have four objects: a circle, a square, a triangle and a custom shape. Refer to Understanding custom polygons in Box2D for more information about custom shapes.

And this is the result:

Left click on a static body with the mouse to shrink it, left click + SPACE to expand it.

Download the source code.

Next time… player, goal and “mass energy”.

  • Quintus

    niceeeeee, but i cant do AS3. It looked cool though :D

  • Pingback: Shrink it Box2D prototype – Step 2 : Emanuele Feronato - italian geek and PROgrammer()

  • jon

    that last level was hard but awesome.

  • Tim


    I’m trying to resize/stretch a box at runtime. Following the ideas in this tutorial series I destroy the fixture and then recreate it. The problem I have is b2ContactListener.EndContact isn’t being called when I destroy the fixture (which was in a contact) and replace with a new fixture (which isn’t in contact). Do you have any suggestions how I might detect whether my box is in contact or not?

    Thanks for another fantastic tutorial by the way!