Pinball and Flipper physics question

I have implemented the beginnings of a pinball game with flippers that are activated by pressing buttons on the side of the machine. When the ball drops and i hit it with the flipper it works.

BUT....

I need to apply force only when the flipper is flipped and hits the ball.

When the ball and flipper collide with no flipper movement the ball should barely react , but when hit by the flipper while the ball is falling then I want to use the applyforce option to make the ball react harder.

I have a listener that watches for the button press to flip the flipper and I have a collision function looking for when the ball collides with the flipper, but again I need to figure out how to make the ball react with applyforce only when hit when the flipper is flipping!

Any ideas??

I have been experimenting with building a pinball game. I have a basic playfield programmed with a bumper, slingshot and flipper. There is no scoring and no sound. This is just to test out the physics, mainly that of the flipper and ball collisions.

I believe that I have the flipper and ball collisions working satisfactory. You are invited to inspect and use my code. You can download it here:

http://martinapps.com/files/pinball physics.zip

My thanks to Jonathan Beebe for his tip about waiting to do the processing associated with a collision event. I'm using the runtime "enterframe" event instead of the timer.performWithDelay that he used. Search for this statement in my code: Runtime:addEventListener( "enterFrame", doCollision )

views:1835 update:2011/9/30 9:15:39
corona forums © 2003-2011