I have two red balls and two yellow balls, which were created from a class Ball. The balls are box2d circles, with sprites attached.

Is there a way in which I can check to see if two balls have collided, and if they are the same colour, remove them?

I can access information about the bodies, but am not sure how to test whether they are the same colour.

I have the following code, but am not sure how to continue

        public void beginContact(Contact contact) {
            Fixture fixtureA = contact.getFixtureA();
            Fixture fixtureB = contact.getFixtureB();

Any ideas on what techniques I can use?




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.