HELP! :( lineardamping not working

The ball keeps on going and going like the bunny we all know…
HELP!

i lost count how long i spent trying to figure this out
the 2 major changes that i did

  1. new build version (2012.806) (been doing it for a few versions)
  2. im using an object to store it in a table… (just tested the code with out the .object. same thing happens so point 2 is excluded)

ive been going in circles for days

here is a stripped down version of my code

can someone tell me if its working in their builds?
if not why wouldn’t it be working?
as always, thanks for any and all help!

[code]
local physics = require “physics”
physics.start(); physics.pause()
physics.setScale( 30 )
physics.setGravity( 0 , 0 ) --Top Down view no gravity…Earth y is 9.8
–physics.setDrawMode(“hybrid”)

– forward declarations and other locals
local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth*0.5
local ballbody = { density=0.8, friction=0.2, bounce=0.5, radius=15 }
local balls = {}

local function ballShot( event )
local t = event.target
local phase = event.phase

if “began” == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true

– Stop current motion, if any
t:setLinearVelocity( 0, 0 )
t.angularVelocity = 0

elseif t.isFocus then
if “moved” == phase then
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false

– Strike the ball!
t:applyForce( (t.x - event.x), (t.y - event.y), t.x, t.y )

end
end

– Stop further propagation of touch event
return true
end

–Spawn the ball Insert into a table for further use
local ball = {}
ball.object = display.newImage(“inkball.png”)
ball.object.id = “ball”
ball.object.alpha = 1
ball.object.linearDamping = 0.3 – Friction on the bg
ball.object.x = screenH/2
ball.object.y = screenW/2
ball.object.isBullet = true
ball.object:addEventListener( “touch”, ballShot )
physics.addBody( ball.object, ballbody )
table.insert(balls, ball)

physics.start()
[/code] [import]uid: 99036 topic_id: 25998 reply_id: 325998[/import]

Did you try setting linear damping AFTER you add the body? I usually set all physics principals after addBody()… maybe it doesn’t matter, but worth a try.

Otherwise, if you can narrow this down to something that worked in a previous build (no matter my point above), then it must be a Daily Build issue, and should be reported a a bug.

Brent Sorrentino
Ignis Design [import]uid: 9747 topic_id: 25998 reply_id: 105246[/import]

Ok, so I’m playing around with this code.

Here is what I think you are trying to do:

Hit the ball, have it slow down after a while?

Is that correct?

It appears as well depending on wear you hit the ball (outside, vs more inside) it will go faster or slower.
I was *Trying* to do a timer.performwithdelay and add damping to it over a period of time, but for whatever reason that wasn’t working.

I’ll wait for you to respond, and we can see what we can cook up.

-ng [import]uid: 61600 topic_id: 25998 reply_id: 105247[/import]

First of all thanks to both of you!

@Brent wow i feel like a dummy! you wouldn’t believe how long i spent trying to figure this out… your solution worked!

i simply put the linear damping after the physics.body and the ball finally slowed down

@nicholasclayg yes that was what i was trying to do, thanks so much for trying it out and getting back to me! im sorry i wasn’t more specific on what it was supposed to do.

i hope one day i can return the favor to both of you!

take care for now.

[import]uid: 99036 topic_id: 25998 reply_id: 105275[/import]

Wow, I feel stupid now. The order of operations came into play on this one! Put it after it works fine. Lol, here I was cooking up some timer function to start at .3 and increase to 100, when all that had to be done was just put it after.

Haha, I feel silly. [import]uid: 61600 topic_id: 25998 reply_id: 105301[/import]

Excellent. I was just about to write and ask about the exact same thing, as I was also having that exact issue. So I’d also like to say cheers.

Many thanks. [import]uid: 88980 topic_id: 25998 reply_id: 105484[/import]