even better
[lua]local physics = require “physics”
physics.start()
physics.setGravity(0,3)
staticMaterial = {friction=.2,bounce=.2}
----------------------------- create new Circle -------------------------------------
local circle = display.newCircle(100,0,20)
physics.addBody(circle, staticMaterial)
----------------------------- create new Ractangle -------------------------------------
local ractangle = display.newRect(60,100,900,40)
physics.addBody(ractangle, “static”, staticMaterial)
function ractangle:touch(event)
if event.phase == “ended” then
ractangle:removeSelf()
end
end
ractangle:addEventListener(“touch”,ractangle)
----------------------------- create new Line -------------------------------------
local i = 1
local tempLine
local ractgangle_hit = {}
local prevX , prevY
local function runTouch(event)
if(event.phase==“began”) then
if(tempLine==nil) then
tempLine=display.newLine(event.x, event.y, event.x, event.y)
tempLine:setColor(255,255,255,255)
tempLine.width=5
prevX = event.x
prevY = event.y
end
elseif(event.phase==“moved”) then
tempLine:append(event.x,event.y-2)
tempLine.width=tempLine.width+0.000001
ractgangle_hit[i] = display.newLine(prevX, prevY, event.x, event.y)
ractgangle_hit[i]:append(event.x,event.y)
ractgangle_hit[i].width=2
ractgangle_hit[i].alpha = 0
local Width = ractgangle_hit[i].width * 0.3
local Height = ractgangle_hit[i].height * 0.3
local lineShape = {-Width,-Height,Width,-Height,Width,Height,-Width,Height}
physics.addBody(ractgangle_hit[i], “static”, { density=0.3, friction=0.7, shape = lineShape})
prevX = event.x
prevY = event.y
i = i + 1
elseif(event.phase==“ended”) then
tempLine.parent.remove(tempLine)
tempLine=nil
end
end
Runtime:addEventListener(“touch”, runTouch)[/lua]
probably you need to optimize code i doubt it will not give good fps but good [import]uid: 12482 topic_id: 10276 reply_id: 37559[/import]