Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Need Urgent he-lp - Phys2D - Bodies doesn't bounce back after collision...

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need Urgent he-lp - Phys2D - Bodies doesn't bounce back after collision...

    In my code there are two balls with certain velocity both from different direction collide with eachother... After Collision they are supposed to bounce back with certain velocity...But in my code they just stuck together the moment the collide eachother.

    I tried to set restitution value 15 for both bodies, but the bodies vanish after collision...
    Any help would be highly appreciated.

    Thanks in advance>>

    protected void init(World world) {
     
    world.setGravity(0,0); //
     
    Body BallA= new Body("Cart", new Circle(15), 100);
     
    Body BallB= new Body("Cart", new Circle(15), 100);
     
     
    BallA.setPosition(150, 375);
    BallB.setPosition(300, 375);
     
    BallA.adjustVelocity(new Vector2f(20f, 0f));
    BallB.adjustVelocity(new Vector2f(-20f, 0f));
     
    //          ball1.getBody().setRestitution(15);
    //          ball2.getBody().setRestitution(15);
     
     
     
    world.add(ball1);
    world.add(ball2);
     
     
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Need Urgent he-lp - Phys2D - Bodies doesn't bounce back after collision...

    Post the Body class.

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need Urgent he-lp - Phys2D - Bodies doesn't bounce back after collision...

    Thanks, Actually I tried different Restitution value between 0.3 to 0.9 and its working fine now.

    However, if u r interested, following are the links:

    Phys2d Javadocs:
    Generated Documentation (Untitled)


    Phys2d SourceCode:
    Index of /phys2d/source/src/net/phys2d/raw

Similar Threads

  1. Phys2d Velocity Problem... Body Movement from Point A to B with Velocity.
    By digital.optiplex in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 1st, 2013, 09:26 AM
  2. Let's Bounce! (game I made for LD warmup weekend)
    By KevinWorkman in forum The Cafe
    Replies: 7
    Last Post: April 17th, 2012, 08:00 AM
  3. Need urgent help regarding java word wrap function.. URGENT
    By coldice in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 16th, 2011, 05:43 AM
  4. Cant get the ball to bounce around the canvass
    By RajivdeCosta in forum What's Wrong With My Code?
    Replies: 16
    Last Post: June 30th, 2011, 10:18 AM