help me plz. how to set ball move direction and hit the wall

hi
i'm newbie for box2D
i try box2D as3.0 by basic code the circle particle move from air to ground because box2D has gravity

but i want to create top view look like pool table

Image
set the ball velocity move direction and i want to check hit the wall how many times

please tell me some class method or a little sample code
First you should set the gravity to "new b2Vec(0, 0);". To move the ball you can use applyImpulse or applyForce methods. To detect collision you should extend "b2ContactListener" class and pass your class to "world.SetContactListener(yourclasshere)". Use "userData" while adding the walls and the ball. For example "ballBodyDef.userData = "ball";" or "wallBodyDef.userData = "wall";" Then in your contact listener get the string from this property and store the number of collisions.
Thanks you.

i understand now (^o^)

Original thread: https://box2d.org/forum/viewtopic.php?t=5745