Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Physic problem..

Author
Message
Alain91
12
Years of Service
User Offline
Joined: 20th Aug 2011
Location: France
Posted: 20th Aug 2011 17:33
I am trying to make this :

You move a bar, a ball fall from the top.
the ball must follow the bar orientation..

here is he code :



It seems to work, but 'sometimes' the ball fall through the bar ..?

Any help is welcome
I included the project in the message.

Alain

Attachments

Login to view attachments
DrT
15
Years of Service
User Offline
Joined: 10th May 2008
Location: 26.78 degrees North, -70.49 degrees West
Posted: 21st Aug 2011 13:30
Try changing your bar from static to kinematic.
SetSpritePhysicsOn ( barreSprite, 1 ) ---->
SetSpritePhysicsOn ( barreSprite, 3 )
Alain91
12
Years of Service
User Offline
Joined: 20th Aug 2011
Location: France
Posted: 22nd Aug 2011 17:27
Thanks for your answer DrT

But I have the same problem.. :/

Any help appreciated
DrT
15
Years of Service
User Offline
Joined: 10th May 2008
Location: 26.78 degrees North, -70.49 degrees West
Posted: 22nd Aug 2011 23:19
Sorry, I should have attached the code I used.

I did make a few additional tweaks.

1) I set the scale so that the size of the soccer ball in reality matches the pixels used for its image.
2) I turned gravity on for the scale used.
3) I removed your sprite visible commands. They are visible by default.
4) I set the bar to be a kinematic object.
5) I set the mass of the soccer ball to its actual mass (physics engines sometime freak out over 0 mass).
6) I gave the ball a coefficient of restititution so that it bounces as expected.
7) I removed the redundant setphysicsshape commands from your do loop.



Hope this helps.
Alain91
12
Years of Service
User Offline
Joined: 20th Aug 2011
Location: France
Posted: 23rd Aug 2011 10:11
Excellent DrT !

This is exactly what I tried to do..

Many thanks for your help!

By the way, I understand that I missed key concepts like scale, gravity, etc..
Could you tell me where you learned this ?
Is there a "box2d for dummies" somewhere ?


Again Thank you a lot!
Alain

Login to post a reply

Server time is: 2024-03-29 08:44:41
Your offset time is: 2024-03-29 08:44:41