2
votes

I have been messing around with Corona SDK for a few weeks now, but have not succeeded in creating a genuine collision between a draggable object and a dynamic object.

What I mean: Like in Justin Smith’s Realistic Summer Sports Simulator, or in Finger Balance -> http://www.youtube.com/watch?v=8_iGFsBUsV8

When the dragged object is dragged to above and stops immediately, the object on top of the dragged object has still a bit of force to above, just like in nature. But in the Drag Physics Sample for Corona SDK for example, there is no such force, the object just glues to the dragged object when it should jump a bit. I hope you understand what I am trying to explain, English is not my native language.

Thanks in advance!

1
Do you mean that, your dragable object and dynamic object become together or did I misunderstand? And do you study physics object types? ( Kinematics, dynamic, static ) - Doğancan Arabacı
This is an example, I tried to use kinematic and dynamic objects, I thought it would be possible to throw the small square in the air with the big square, but it isn’t. local physics = require "physics" physics.start() physics. setScale(90) local rect = display.newRect (250,450,50,50) local rect2 = display.newRect (175, 650, 200, 200) physics.addBody(rect, "dynamic") physics.addBody(rect2, "kinematic") function drag (event) if event.phase == "moved" then rect2.x = event.x - event.xStart + 275 rect2.y = event.y - event.yStart + 750 end end Runtime: addEventListener ("touch", drag) - user2281843

1 Answers

0
votes

Once you let the physics subsystem manage an object, you cannot alter it's coordinates 'manually'. The physics will at least hickup then.

But you can exert forces to the object or set it's velocity via applyForce and setLinearVelocity.

If you want to drag a physics object you can use the so called 'touch joints'. If you want more control try something like:

function drag(e)
  if e.phase == 'moved' then
     e.target:setVelocity( (e.x-e.target.x)*c, (e.y-e.target.y)*c )   
  end
end