Physics Finger Ball Hit Example?

6 replies [Last post]
iBobX
User offline. Last seen 33 weeks 11 hours ago. Offline
Joined: 12 Apr 2010

Hi, maybe this is a dumb question?, but I am very new to physics here...
I want to do something like the pool table game example, but I want to hit the white ball with my finger... :)
Is there an example on how to simulate a ball hit with the finger touch?
THANKS!!!

Replies

MikeHart
User offline. Last seen 1 week 2 days ago. Offline
Joined: 22 Mar 2010

Example... not that I know off. You are talking about the physics in the game edition, right?

iBobX
User offline. Last seen 33 weeks 11 hours ago. Offline
Joined: 12 Apr 2010

Hi Mike, Yeah, Game Edition, I looked around but didn't found anything so yes I guess there's not...
Thanks.

MikeHart
User offline. Last seen 1 week 2 days ago. Offline
Joined: 22 Mar 2010

You didn't ask for a suggestion, but hey...

how about you create a circle, set its alpha value to 0, attach a circular physic body to it, and let this circle follow your touch event. With the correct collision filtering/masking you can then use your finger to hit the ball.

iBobX
User offline. Last seen 33 weeks 11 hours ago. Offline
Joined: 12 Apr 2010

Yeah I've been testing with a circle; the collision works, but still trying to figure the speed thing... I am thinking about maybe create a variable that collects the start and end point and using the collision use the applyForce somehow with the values of the start/end touch event variables... I'll test that later.
Thank for your suggestion!
Bob.

OderWat
User offline. Last seen 28 weeks 17 hours ago. Offline
Joined: 4 Jun 2010

Hmm.... recognizing and register the "touch begin" point... getTimer()... check "collision" with a simple distance to object-center - radius algorithm (on move events)... when hit... check for the time since start.. calculate the distance of the move... use the time to calculate the speed... and hence the force.. the direction (vector)... apply that to the center of the hit object.

Would be enough for simple "marble" rolling games (where you ignore where you hit the object).

iBobX
User offline. Last seen 33 weeks 11 hours ago. Offline
Joined: 12 Apr 2010

Hmmm, I'll need to read more about physic then... I though the box library will help a little more... :)
Thanks a lot for the comments and ideas!
iBob.

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.