can any one explain what’s wrong with my code so that object not stopping after collision with floor
local object = display.newImage( "icon-small.png" ,200,200) object.id = "ball object" function object:touch( event ) if event.phase == "began" then print( "Touch event began on: " .. self.id ) start = event -- set touch focus display.getCurrentStage():setFocus( self ) self.isFocus = true elseif self.isFocus then if event.phase == "moved" then print( "Moved phase of touch event detected." ) sling = event function angleOf( a, b ) return math.atan2( b.y - a.y, b.x - a.x ) \* 180 / math.pi end function lengthOf( a, b ) local width, height = b.x-a.x, b.y-a.y return math.sqrt(width\*width + height\*height) end local iteration = 0.1 function trajectory( velocity, angle, iteration ) local points, r, h, f = calcTrajectoryPoints( 0, 0, velocity, angle, iteration ) print( 'angle: ', angle ) print( 'velocity: ', velocity ) print( 'range: ', r ) print( 'height: ', h ) print( 'flight time: ', f ) for i=1, #points do --print( math.round( points[i].x ), math.round( points[i].y ) ) display.newCircle( start.x + points[i].x, start.y - points[i].y, (points[i].velocityx + points[i].velocityy) \* 0.1 ) end return points end local angle = math.abs(angleOf( sling, start ) ) local distance = lengthOf( sling, start ) --local points = trajectory( distance, angle, iteration ) print (math.cos(37/180\*math.pi)) print(math.sin(37/180\*math.pi)) elseif event.phase == "ended" or event.phase == "cancelled" then -- reset touch focus display.getCurrentStage():setFocus( nil ) self.isFocus = nil end end return true end object:addEventListener( "touch", object ) local kecepatan = 300 --kecepatan dengan sudut local sudut = 80 local gravitasi = 10 local waktu = 9/4 print("tinggi maksimal : "..(math.pow(kecepatan,2)\*math.pow(math.sin(sudut/180\*math.pi),2))/(2\*gravitasi).." meter") print("waktu bola mencapai titik tertinggi : "..(kecepatan\*(math.sin(sudut/180\*math.pi)))/gravitasi.." sekon") print("jarak maksimal : "..(math.pow(kecepatan,2)\*(math.sin((2\*sudut)/180\*math.pi)))/gravitasi.." meter") print("waktu maksimal : "..((2\*kecepatan)\*(math.sin(sudut/180\*math.pi)))/gravitasi.." sekon") print("kecepatan bola pada waktu 9/4 sekon(kecepatan akar vx^2,vy^2) : akar "..math.pow(kecepatan\*math.cos(sudut/180\*math.pi),2)..","..math.pow((kecepatan\*math.sin(sudut/180\*math.pi))-(gravitasi\*waktu),2).." = "..math.sqrt(math.pow(kecepatan\*math.cos(sudut/180\*math.pi),2)+math.pow((kecepatan\*math.sin(sudut/180\*math.pi))-(gravitasi\*waktu),2)).." meter/sekon") local physics = require("physics") physics.start() physics.setGravity( 0,9.8 ) physics.setDrawMode( "normal" ) local lantai = display.newRect(0,215,480,10) lantai.anchorX = 0 lantai.anchorY = 0 physics.addBody(lantai, "static", { density=21,bounce=0.2, friction=1.0 } ) local myCircle = display.newImage( "ball.png",50, 200) myCircle.anchorX = 0.5 myCircle.anchorY = 0.5 myCircle.width = 30 myCircle.height = 30 myCircle:setFillColor( 1 ) physics.addBody( myCircle, { bounce=0.1, density=1.0, radius=15 } ) local fps = 0 for i=0,((((2\*kecepatan)\*(math.sin(sudut/180\*math.pi)))/gravitasi)\*display.fps) do local vx = kecepatan\*math.cos(sudut/180\*math.pi) local vy = (kecepatan\*math.sin(sudut/180\*math.pi))-(gravitasi\*fps) local r = ((math.pow(kecepatan,2)\*(math.sin((2\*sudut)/180\*math.pi)))/gravitasi)/display.fps local h = ((math.pow(kecepatan,2)\*math.pow(math.sin(sudut/180\*math.pi),2))/(2\*gravitasi))/display.fps myCircle:setLinearVelocity(vx,vy) myCircle.angularVelocity = math.sqrt(math.pow(vx,2)+math.pow(vy,2)) --kecepatan putaran bola fps = fps + 1/display.fps local Circle0 = display.newCircle( myCircle.x, myCircle.y, 5 ) Circle0.anchorX = 0.5 Circle0.anchorY = 0.5 Circle0:setFillColor( 0.5 ) local Circle = display.newCircle( myCircle.x+r, myCircle.y, 5 ) Circle.anchorX = 0.5 Circle.anchorY = 0.5 Circle:setFillColor( 0.5 ) local Circle2 = display.newCircle((myCircle.x+(r/2)), myCircle.y-h, 5 ) Circle2.anchorX = 0.5 Circle2.anchorY = 0.5 Circle2:setFillColor( 0.5 ) print(r.."/"..h.."/"..vx.."/"..vy) end local function onLocalCollision( self, event ) print("kenek") end myCircle.collision = onLocalCollision myCircle:addEventListener( "collision", myCircle )