Example usage for com.badlogic.gdx.physics.box2d.joints MouseJoint getBodyB

List of usage examples for com.badlogic.gdx.physics.box2d.joints MouseJoint getBodyB

Introduction

In this page you can find the example usage for com.badlogic.gdx.physics.box2d.joints MouseJoint getBodyB.

Prototype

public Body getBodyB() 

Source Link

Document

Get the second body attached to this joint.

Usage

From source file:org.ams.testapps.paintandphysics.cardhouse.CardMover.java

License:Open Source License

private boolean hasStoredJointForThisThing(Thing thing) {
    for (MouseJoint mouseJoint : mouseJointStorage) {
        Thing t = (Thing) mouseJoint.getBodyB().getUserData();

        if (t == thing)
            return true;
    }//ww  w . ja  v  a2 s .c o m
    return false;
}

From source file:org.ams.testapps.paintandphysics.cardhouse.CardMover.java

License:Open Source License

private void destroyMouseJoints(Thing thing) {
    if (debug)// ww w.j  av  a2 s  .c o  m
        debug("Destroying mouse joints for thing " + thing + ".");

    // destroy all the ones controlled by this CardMover
    for (int i = mouseJointStorage.size - 1; i >= 0; i--) {
        MouseJoint mouseJoint = mouseJointStorage.get(i);
        Body b = mouseJoint.getBodyB();

        if (thing.getBody() == b) {
            destroyJoint(mouseJoint);
            mouseJointStorage.removeIndex(i);
        }
    }

    /*for (JointEdge jointEdge : thing.getBody().getJointList()) {
            if (jointEdge.joint instanceof MouseJoint){
            
                    world.world.destroyJoint(jointEdge.joint);
            }
    }*/

}

From source file:org.ams.testapps.paintandphysics.cardhouse.CardMover.java

License:Open Source License

/** Count the cards being controlled. */
private int getNumberOfThingsRepresentedInStore() {
    Set<Body> thingCountingSet = new HashSet<Body>();

    for (MouseJoint mouseJoint : mouseJointStorage) {
        Body body = mouseJoint.getBodyB();
        thingCountingSet.add(body);/*from w w w.j a  va 2s .  c o  m*/
    }
    return thingCountingSet.size();

}

From source file:org.ams.testapps.paintandphysics.cardhouse.CardMover.java

License:Open Source License

private void notifyListenersAddedRemoved() {
    if (debug)/*from  ww  w. j  a  v a2 s . c  o  m*/
        debug("Updating cards.");

    Set<PPPolygon> newCards = new HashSet<PPPolygon>();

    for (int i = 0; i < mouseJointStorage.size; i++) {
        MouseJoint mouseJoint = mouseJointStorage.get(i);

        Color color = cheatColors[(mouseJointStorage.size - i - 1) / 2];

        Body b = mouseJoint.getBodyB();
        Thing thing = (Thing) b.getUserData();
        PPPolygon card = (PPPolygon) thing.getUserData();

        updateColor(card, color);

        newCards.add(card);
    }

    // notify listeners about removed cards
    for (PPPolygon card : cards) {
        boolean removed = !newCards.contains(card);
        if (removed) {

            updateColor(card, cardColor); // reset color on removed cards

            for (CardMoverListener cardMoverListener : cardMoverListeners) {
                cardMoverListener.removed(card);
            }
        }
    }

    // notify listeners about added cards
    for (PPPolygon card : newCards) {
        boolean newCard = !cards.contains(card);
        if (newCard) {
            for (CardMoverListener cardMoverListener : cardMoverListeners) {
                cardMoverListener.added(card);
            }
        }
    }

    cards = newCards;

}

From source file:org.ams.testapps.paintandphysics.cardhouse.CardMover.java

License:Open Source License

private void resetColor(MouseJoint mouseJoint) {
    Body b = mouseJoint.getBodyB();
    Thing thing = (Thing) b.getUserData();

    PPPolygon card = (PPPolygon) thing.getUserData();

    updateColor(card, cardColor);// w  w  w .j  av a 2 s. co  m
}