Need platforms to not get stuck or placed in static floors

Kinda a funny problem I think. This is the basic drag me code with the addition of making the dragged object no longer physical for the duration of the drag. Which works out great for the drag, but when I let go, I can put platforms inside of static floors.

I know this is somehow possible, I’ve seen it done in bubble ball, I just need the platform to kick itself out of the static object at the end of the drag. Any help would be much appreciated.

[code]

local function startDrag( event )
local t = event.target

local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true

– Store initial position
t.x0 = event.x - t.x
t.y0 = event.y - t.y

– Make body type temporarily “kinematic” (to avoid gravitional forces)
event.target.bodyType = “kinematic”

–make platform and object non-physical
event.target.isBodyActive = false

– Stop current motion, if any
event.target:setLinearVelocity( 0, 0 )
event.target.angularVelocity = 0

elseif t.isFocus then
if “moved” == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0

elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false

event.target.isBodyActive = true

– Switch body type back to “dynamic”, unless we’ve marked this sprite as a platform
if ( not event.target.isPlatform ) then
event.target.bodyType = “dynamic”

end

end

end

– Stop further propagation of touch event!
return true
end
[/code] [import]uid: 42079 topic_id: 8162 reply_id: 308162[/import]

How about always setting it to dynamic in the ended phase, but when its marked as a platform set a 100 millisecond timer to fire which then sets it back to static. That should give the platform enough time to pop back into place and then be made static again. [import]uid: 8271 topic_id: 8162 reply_id: 29127[/import]

Thanks for the response horace.

My platforms actually return to kinematic, it’s the drag me code with addition of isBodyActive little loop, I tested them going to static, but you can’t drag anything static so unless their something I need to add that won’t work. My character and platforms work great because they are dynamic and kinematic you can’t put them in each other, it’s just the floor.

The problem is you can lay the kinematic platforms right on top of the static floors or walls. Anything anyone else can think of would be great, thanks. [import]uid: 42079 topic_id: 8162 reply_id: 29181[/import]

Tried the timer, didn’t work for me. This has to be fairly easy I’m thinking. Thanks if anyone can throw me a bone, I would love it. [import]uid: 42079 topic_id: 8162 reply_id: 29759[/import]