Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8045425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:32:35+00:00 2026-06-05T05:32:35+00:00

I use box2dweb. I am trying to develop a game. At some point I

  • 0

I use box2dweb. I am trying to develop a game. At some point I need to find out the contact point between a “Circle” and “Box”. All I know is it can be done using b2ContactListener. We can receive contact data by implementing b2ContactListener using Post-Solve Event. Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:32:37+00:00Added an answer on June 5, 2026 at 5:32 am

    You are on the right track there are various events you can hook into with the b2ContactListener:

    var b2Listener = Box2D.Dynamics.b2ContactListener;
    
    //Add listeners for contact
    var listener = new b2Listener;
    
    listener.BeginContact = function(contact) {
        //console.log(contact.GetFixtureA().GetBody().GetUserData());
    }
    
    listener.EndContact = function(contact) {
        // console.log(contact.GetFixtureA().GetBody().GetUserData());
    }
    
    listener.PostSolve = function(contact, impulse) {
        if (contact.GetFixtureA().GetBody().GetUserData() == 'ball' || contact.GetFixtureB().GetBody().GetUserData() == 'ball') {
            var impulse = impulse.normalImpulses[0];
            if (impulse < 0.2) return; //threshold ignore small impacts
            world.ball.impulse = impulse > 0.6 ? 0.5 : impulse;
            console.log(world.ball.impulse);
        }
    }
    
    listener.PreSolve = function(contact, oldManifold) {
        // PreSolve
    }
    
    this.world.SetContactListener(listener);
    

    Just remove the postSolve code and depending on what you need to do hook into the appropriate events.

    Seth ladd has some great articles on his blog about collision/reacting to them. This is where I picked up these bits so full credit goes to him.

    I hope this helps.

    Thanks,
    Gary

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use case: I've just entered insert mode, and typed some text. Now I want
use warnings; use Test::More; use File::Find::Rule; use Test::File::Find::Rule; my $rule = File::Find::Rule->file->name('*.pl')->not_grep(qr/^\s*use\s+strict;/m, sub {
Use Memcache php class to interact with the memcached. At the beginning all works
Use case: I find a piece of code that I do not understand at
use strict; my $world =52; my $in = 42 ; my $world=42; my $out
Use a hidden field will fix my issue... i got it.. Hi All, I
I use C++ Builder 2010 and I could'nt figure out how to change keyboard
use grep command to find txt files containing telephone number. telephone number format could
Use case: we have some project meta-data files which we want tracked, but are
Use case: A does something on his box and gots stuck. He asks B

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.