I’m having an issue where the ball doesn’t stop rolling when using corona physics until it collides with something. So the ball can roll VERYYYY slowly from one side of the screen to the other without actually stopping until it hits the wall on the other side.
I’m sure there is a way around this, or I’m possibly doing it wrong as I’m new to this. Doing a search I found someone who posted similar on stackoverflow and was told to turn the friction up (which I have done in testing) but it didn’t help me and the poster of it originally never replied.
Here is my code (well the current version at least, been lots of changes while trying to figure this out)
local physics = require "physics"
physics.start()
local myRectangle = display.newRect(-200, 300, 800, 800)
myRectangle:setFillColor(100, 100, 250)
physics.addBody( myRectangle, "static", { friction = 100} )
local myRectangle2 = display.newRect(490, 0, 800, 800)
myRectangle2:setFillColor(100, 100, 250)
physics.addBody( myRectangle2, "static", { friction = 100} )
local myRectangle3 = display.newRect(-30, 250, 50, 50)
myRectangle:setFillColor(100, 100, 250)
physics.addBody( myRectangle2, "static", { density=1.6, friction=100, bounce=1} )
myDynamicImage = display.newImageRect( "img/ball.png", 34, 34 )
myDynamicImage.x = 0
myDynamicImage.y = 0
physics.addBody( myDynamicImage, { friction = 100, radius = 17 ,bounce = 0.3} )
myDynamicImage:applyForce(1, 0, myDynamicImage.x, myDynamicImage.y)
I thought one option could be to check the current force on the object (though I’m not 100% certain how to do that yet) and once it gets below a certain point to slowly take the force away manually (again not certain how to do that yet). But I’m sure there has to be a better way to handle this considering the physics system seems pretty good, so assuming I’m just doing something wrong!
Can anyone point me in the right direction for this? [import]uid: 133056 topic_id: 24196 reply_id: 324196[/import]
[import]uid: 52491 topic_id: 24196 reply_id: 97647[/import]