Well, I think you could make a MouseJoint to it and remove it after a certain amount of time? (But that means that other forces will be counteracted as well, I don't know if that is what you want.)
Not kinda understand your suggestion.
Can you run my attached lua?
Once you run it, press "b" and it will move to top right
I believe you can visualize after you run my script
The keypoint is to "stop" after the "applyForce" applied
If you only want the force to be applied after, say, 5 seconds but have gravity and so still act on the ball in the mean time, you could do something like:
timer = nil
function love.keypressed(key) -- I wouldn't apply force while holding a key
if key == 'b' then
timer = 5
end
end
function love.update(dt)
world:update(dt)
if timer then
timer = timer - dt
if timer <= 0 then
timer = nil
ball.b:applyForce(300, -320)
end
end
end
function love.update(dt)
world:update(dt)
if love.keyboard.isDown("p") then --press the left arrow key to push the ball to the left
ball.b:applyForce(horiForce, vertForce * -1)
text = 'press b'.."\n" .. text
end
if love.keyboard.isDown("o") then --press the left arrow key to push the ball to the left
ball.b:destroy()
end
weilies wrote:Destroy method seems like "destroy" my window, my whole app crashed
No, I didn't mean that. What I meant was:
Create a MouseJoint
When you want the body to move, destroy the MouseJoint. (NOT the body.)
weilies wrote:i figure out a way
which is NOT to trigger following function "world:update(dt)"
Oh, but that stops all physics. I thought you didn't want that.
Seriously though, if what you want to do is so simple, it might be easier not to use love.physics. (Seeing as you don't seem to need any complex collision testing or anything.)
Yes, but no, I prefer to use Wht the framework provided rather to dirty my hand on my own throw ball logic
My gameplay is based on angle and force user selected, throw a ball and see how far it can goes
And if my ball hit ground and a superpower item on the ground, mean my ball touch the superpower object(collide) I will need to play an animation and change the force