title: Box2D(LibGDX) - strange behaviour of ball
body: <p>I am trying to create simple tennis game. Each side has a wall. There are also a box and a ball. My environment doesn't have gravity. The box and the ball don't have any velocity. When the box contacts the ball(I move this by mouse with different speed), it(the ball) just changes its position and doesn't continue moving and sometimes these objects don't collide with each other:</p>
  
  <p><img src="https://i.stack.imgur.com/kxaUJ.png" alt="enter image description here"></p>
  
  <p>I want the box can strike the ball using different angle and strength. </p>
  
  <p><img src="https://i.stack.imgur.com/GI9bz.png" alt="enter image description here"></p>
  
  <p>How can I do this? What should I change in the properties of the ball and the box?</p>
  
  <p>The code snippet is below:</p>
  
  <pre><code>public void createBall(Vector2 position, Vector2 velocity, float angle, Object userData){
      // First we create a body definition
      BodyDef bodyDef = new BodyDef();
      // We set our body to dynamic, for something like ground which doesnt move we would set it to StaticBody
      bodyDef.type = BodyType.DynamicBody;
      // Set our body's starting position in the world
      bodyDef.position.set(position);
  
      // Create our body in the world using our body definition
      Body body = world.createBody(bodyDef);
  
      body.setUserData(userData);
      // Create a circle shape and set its radius to 6
      CircleShape circle = new CircleShape();
      circle.setRadius(10f);
  
      PolygonShape poly = new PolygonShape();     
      poly.setAsBox(12, 12);
  
      // Create a fixture definition to apply our shape to
      FixtureDef fixtureDef = new FixtureDef();
      fixtureDef.shape = circle;
      fixtureDef.density = 0.0f; 
      fixtureDef.friction = 0.2f;
      fixtureDef.restitution = 1f; // Make it bounce a little bit
      fixtureDef.isSensor=false;
  
      // Create our fixture and attach it to the body
      Fixture f = body.createFixture(fixtureDef);
      f.setUserData("ball");      
      circle.dispose();   
  }
  
    private Body createBox(World world, float width, float height, float density) {
          BodyDef def = new BodyDef();
          def.type =  BodyType.KinematicBody;
          Body box = world.createBody(def);
  
          PolygonShape poly = new PolygonShape();
          poly.setAsBox(width/2, height/2);
  
          FixtureDef fixtureDef = new FixtureDef();
          fixtureDef.shape = poly;
          fixtureDef.density = 0.0f; 
          fixtureDef.friction = 0.3f;
          fixtureDef.restitution = 0.1f; // Make it bounce a little bit
          fixtureDef.isSensor=false;
  
          // Create our fixture and attach it to the body
          Fixture f = box.createFixture(fixtureDef);
          f.setUserData("platform");
          poly.dispose();
  
          return box;
      }
          public void createWall(World world, Vector2 position, float hx, float hy){
      // Create our body definition
      BodyDef groundBodyDef =new BodyDef();  
      // Set its world position
      groundBodyDef.position.set(position);  
          groundBodyDef.type=BodyType.StaticBody;
      // Create a body from the defintion and add it to the world
      Body groundBody = world.createBody(groundBodyDef);  
  
      // Create a polygon shape
      PolygonShape groundBox = new PolygonShape();  
      // Set the polygon shape as a box which is twice the size of our view port and 20 high
      // (setAsBox takes half-width and half-height as arguments)
      groundBox.setAsBox(hx, hy);
      // Create a fixture from our polygon shape and add it to our ground body  
      groundBody.createFixture(groundBox, 0.0f); 
      // Clean up after ourselves
      groundBox.dispose();
  }
  </code></pre>