"static" through "dinamic" object?

How can i avoid that, when i drag a “static” object, it passes through a “dinamic” one?? 

How can i avoid that, when i drag a “static” object, it passes through a “dinamic” one?? 

Sorry:

How can i avoid that, when i drag a “DINAMIC” object, it passes through a “STATIC” one?? 

You can use a touch joint like so

[lua]

local function onTouch(self,e)

if e.phase == “began” then

display.getCurrentStage():setFocus(  self )
self.isFocus = true

self.tempJoint = physics.newJoint(“touch”, self, e.x,e.y)

elseif e.phase == “moved” then

self.tempJoint:setTarget(e.x, e.y)

elseif e.phase == “ended” then
self.tempJoint:removeSelf()

display.getCurrentStage():setFocus(  nil )
self.isFocus = false
end

return true

end

yourobject.touch = onTouch

yourobject:addEventListener(“touch”)

[/lua]

This will cause the object to be acted upon by gravity at the touch position which you may or may not want.

If you want the object to not act this way you can use

yourobject.isFixedRotation = true

after you initially create yourobject and add its physics properties .

You may also find that the object lags more when moving due to all the extra physics calculation being carried out, but give it a try to see if it’s too much of an issue.  I used this technique for my Deflect app.

If the lag is too much then sorry I’m not sure.

How can i avoid that, when i drag a “static” object, it passes through a “dinamic” one?? 

Sorry:

How can i avoid that, when i drag a “DINAMIC” object, it passes through a “STATIC” one?? 

You can use a touch joint like so

[lua]

local function onTouch(self,e)

if e.phase == “began” then

display.getCurrentStage():setFocus(  self )
self.isFocus = true

self.tempJoint = physics.newJoint(“touch”, self, e.x,e.y)

elseif e.phase == “moved” then

self.tempJoint:setTarget(e.x, e.y)

elseif e.phase == “ended” then
self.tempJoint:removeSelf()

display.getCurrentStage():setFocus(  nil )
self.isFocus = false
end

return true

end

yourobject.touch = onTouch

yourobject:addEventListener(“touch”)

[/lua]

This will cause the object to be acted upon by gravity at the touch position which you may or may not want.

If you want the object to not act this way you can use

yourobject.isFixedRotation = true

after you initially create yourobject and add its physics properties .

You may also find that the object lags more when moving due to all the extra physics calculation being carried out, but give it a try to see if it’s too much of an issue.  I used this technique for my Deflect app.

If the lag is too much then sorry I’m not sure.