When the screen is touched several times, the position of the Rectange is not the same
local physics = require( "physics" )
physics:start( true )
physics.setGravity( 0, 0 )
local levelGroup = display.newGroup()
local function loadLevel()
local o = display.newRect(100,100,50,50)
physics.addBody( o, "dynamic", { density=1.0, friction=1.0, bounce=0.0 } )
levelGroup:insert(o)
end
local function clearLevel()
for i = levelGroup.numChildren,1,-1 do
local child = levelGroup[i]
child.parent:remove( child )
child = nil
end
end
local function onTouch(event)
if event.phase == "ended" then
clearLevel()
loadLevel()
end
end
Runtime:addEventListener( "touch", onTouch )
[import]uid: 12088 topic_id: 7854 reply_id: 307854[/import]