Hi.
I have physics ball body. I apply force to it every frame when game is running and I want it to stay still when game is paused. But when I set its forces and velocity to 0, it still keeps moving very slowly to the same direction where it was going (like 1 pixel per second).
You can test the behavior with following code:
[lua]local physics = require(“physics”)
local running = false
physics.start()
physics.setGravity( 0, 0)
local playBall= display.newCircle(200, 580,20)
physics.addBody(playBall, {density=4.14, friction=0.3, bounce=0.2, radius=20})
local everyFrame = function(event)
if running then
playBall:applyForce(0,-4.8, playBall.x, playBall.y)
end
end
Runtime:addEventListener(“enterFrame”, everyFrame)
local startStop = display.newRoundedRect(390, 400, 100, 50, 10)
local runEvent = function(event)
if event.phase == “ended” then
if not running then
running = true
else
running = false
playBall:setLinearVelocity(0,0)
playBall.angularVelocity = 0
playBall.collisionBit = 0
playBall.x = 200; playBall.y = 580
end
end
end
startStop:addEventListener(“touch”, runEvent)[/lua]
[import]uid: 56131 topic_id: 14905 reply_id: 314905[/import]
