Tim is taking a break this week from his “Game in 8 Minutes” series, but has still provided you with a very useful tutorial on dragging physical objects. (somebody could make a really cool shuffleboard game with this!)

  1. Please add 3 things: multi-touch dragging, resizing of objects using multi-touch and replacing the squares with images 😉

    Yes, you know where I’m going with that, but the principle is widely useful and often implemented in many iPhone apps.

    Awesome Hetal, thanks again.

  2. Thanks for the comment, Matt. Two of the improvements you suggest are pretty easy:

    To use images, in place of the for() loop that calls newRect() you can use newImage(), e.g.:

    local puck1 = display.newImage(“image1.png”)
    local puck2 = display.newImage(“image2.png”)
    local puck3 = display.newImage(“image3.png”)


    To enable multitouch, you just have add one line of code:



    To resize images with multi-touch requires some more work, but the PinchZoomGesture sample in the Corona SDK (Interface/PinchZoomGesture) provides a good starting point.


  3. Hi Tim

    Great tutorial and many thanks!

    However i want to ask where the sample code is? I could not find it (or i did not know where to look for it) in the latest corona sdk version?!


  4. Hi Tim

    I loved the tutorial, very good, thanks! But I could not find the tutorial in the sdk sample code for this in the latest sdk? Or maybe i misunderstood?


  5. Hey Tim i’m new to Corona and i was wondering if you could help me with a problem i was having on my app, so i have an object following my “touch” and i want a second object to follow the first object at a certain rate/speed( like a game of tag) but i have been searching for the code but haven’t had any luck finding anything about it so i was wondering if you could help me.

  6. I am enjoying the tutorials very much. Corona is definitely expediting the development process. I noticed several others in various forums have asked a question similar to the one I have, but there doesn’t appear to be any solid guidance anywhere. Specifically, there are a few of us out here that are having issues combining physics functionality with dragging functionality.

    Specifically, when I add the following three lines of code to this demo, it breaks.

    physics = require(‘physics’)

    physics:addBody( button, {density=3.0, friction=1.0, bounce=0.03})

    Specifically, there error message presented is “…bad argument #-2 to ‘addBody’ (Proxy expected, got nil)”

    Can you shed some light on what issues there are on dragging physical objects in a gravitational world? Any insight/direction would be greatly appreciated.


  7. Sorry, I typed that too quickly. Actual physics code is as follows:

    local physics = require(‘physics’);

    Still get the same “…bad argument #-2 to ‘addBody’ (Proxy expected, got nil)” error message. :-(

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>