List of usage examples for com.badlogic.gdx.physics.box2d Joint setUserData
public void setUserData(Object userData)
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DMapObjectParser.java
License:Apache License
/** creates a {@link Joint} from a {@link MapObject} * @param mapObject the {@link Joint} to parse * @return the parsed {@link Joint} */ public Joint createJoint(MapObject mapObject) { if ((mapObject = listener.createJoint(mapObject)) == null) return null; MapProperties properties = mapObject.getProperties(); JointDef jointDef;//from w ww.j av a 2s . c om String jointType = getProperty(properties, aliases.jointType, ""); if (jointType.equals(aliases.distanceJoint)) { DistanceJointDef distanceJointDef = new DistanceJointDef(); assignProperties(distanceJointDef, heritage); assignProperties(distanceJointDef, mapProperties); assignProperties(distanceJointDef, layerProperties); assignProperties(distanceJointDef, properties); jointDef = distanceJointDef; } else if (jointType.equals(aliases.frictionJoint)) { FrictionJointDef frictionJointDef = new FrictionJointDef(); assignProperties(frictionJointDef, heritage); assignProperties(frictionJointDef, mapProperties); assignProperties(frictionJointDef, layerProperties); assignProperties(frictionJointDef, properties); jointDef = frictionJointDef; } else if (jointType.equals(aliases.gearJoint)) { GearJointDef gearJointDef = new GearJointDef(); assignProperties(gearJointDef, heritage); assignProperties(gearJointDef, mapProperties); assignProperties(gearJointDef, layerProperties); assignProperties(gearJointDef, properties); jointDef = gearJointDef; } else if (jointType.equals(aliases.mouseJoint)) { MouseJointDef mouseJointDef = new MouseJointDef(); assignProperties(mouseJointDef, heritage); assignProperties(mouseJointDef, mapProperties); assignProperties(mouseJointDef, layerProperties); assignProperties(mouseJointDef, properties); jointDef = mouseJointDef; } else if (jointType.equals(aliases.prismaticJoint)) { PrismaticJointDef prismaticJointDef = new PrismaticJointDef(); assignProperties(prismaticJointDef, heritage); assignProperties(prismaticJointDef, mapProperties); assignProperties(prismaticJointDef, layerProperties); assignProperties(prismaticJointDef, properties); jointDef = prismaticJointDef; } else if (jointType.equals(aliases.pulleyJoint)) { PulleyJointDef pulleyJointDef = new PulleyJointDef(); assignProperties(pulleyJointDef, heritage); assignProperties(pulleyJointDef, mapProperties); assignProperties(pulleyJointDef, layerProperties); assignProperties(pulleyJointDef, properties); jointDef = pulleyJointDef; } else if (jointType.equals(aliases.revoluteJoint)) { RevoluteJointDef revoluteJointDef = new RevoluteJointDef(); assignProperties(revoluteJointDef, heritage); assignProperties(revoluteJointDef, mapProperties); assignProperties(revoluteJointDef, layerProperties); assignProperties(revoluteJointDef, properties); jointDef = revoluteJointDef; } else if (jointType.equals(aliases.ropeJoint)) { RopeJointDef ropeJointDef = new RopeJointDef(); assignProperties(ropeJointDef, heritage); assignProperties(ropeJointDef, mapProperties); assignProperties(ropeJointDef, layerProperties); assignProperties(ropeJointDef, properties); jointDef = ropeJointDef; } else if (jointType.equals(aliases.weldJoint)) { WeldJointDef weldJointDef = new WeldJointDef(); assignProperties(weldJointDef, heritage); assignProperties(weldJointDef, mapProperties); assignProperties(weldJointDef, layerProperties); assignProperties(weldJointDef, properties); jointDef = weldJointDef; } else if (jointType.equals(aliases.wheelJoint)) { WheelJointDef wheelJointDef = new WheelJointDef(); assignProperties(wheelJointDef, heritage); assignProperties(wheelJointDef, mapProperties); assignProperties(wheelJointDef, layerProperties); assignProperties(wheelJointDef, properties); jointDef = wheelJointDef; } else throw new IllegalArgumentException( ClassReflection.getSimpleName(JointType.class) + " " + jointType + " is unknown"); assignProperties(jointDef, properties); Joint joint = jointDef.bodyA.getWorld().createJoint(jointDef); joint.setUserData(getProperty(properties, aliases.userData, joint.getUserData())); joints.put(findAvailableName(mapObject.getName(), joints), joint); listener.created(joint, mapObject); return joint; }
From source file:de.fhkoeln.game.utils.Box2DMapObjectParser.java
License:Apache License
/** creates a {@link com.badlogic.gdx.physics.box2d.Joint} from a {@link com.badlogic.gdx.maps.MapObject} * @param mapObject the {@link com.badlogic.gdx.physics.box2d.Joint} to parse * @return the parsed {@link com.badlogic.gdx.physics.box2d.Joint} */ public Joint createJoint(MapObject mapObject) { if ((mapObject = listener.createJoint(mapObject)) == null) return null; MapProperties properties = mapObject.getProperties(); JointDef jointDef;//from w w w .j a va 2s . c o m String jointType = getProperty(properties, aliases.jointType, ""); if (jointType.equals(aliases.distanceJoint)) { DistanceJointDef distanceJointDef = new DistanceJointDef(); assignProperties(distanceJointDef, heritage); assignProperties(distanceJointDef, mapProperties); assignProperties(distanceJointDef, layerProperties); assignProperties(distanceJointDef, properties); jointDef = distanceJointDef; } else if (jointType.equals(aliases.frictionJoint)) { FrictionJointDef frictionJointDef = new FrictionJointDef(); assignProperties(frictionJointDef, heritage); assignProperties(frictionJointDef, mapProperties); assignProperties(frictionJointDef, layerProperties); assignProperties(frictionJointDef, properties); jointDef = frictionJointDef; } else if (jointType.equals(aliases.gearJoint)) { GearJointDef gearJointDef = new GearJointDef(); assignProperties(gearJointDef, heritage); assignProperties(gearJointDef, mapProperties); assignProperties(gearJointDef, layerProperties); assignProperties(gearJointDef, properties); jointDef = gearJointDef; } else if (jointType.equals(aliases.mouseJoint)) { MouseJointDef mouseJointDef = new MouseJointDef(); assignProperties(mouseJointDef, heritage); assignProperties(mouseJointDef, mapProperties); assignProperties(mouseJointDef, layerProperties); assignProperties(mouseJointDef, properties); jointDef = mouseJointDef; } else if (jointType.equals(aliases.prismaticJoint)) { PrismaticJointDef prismaticJointDef = new PrismaticJointDef(); assignProperties(prismaticJointDef, heritage); assignProperties(prismaticJointDef, mapProperties); assignProperties(prismaticJointDef, layerProperties); assignProperties(prismaticJointDef, properties); jointDef = prismaticJointDef; } else if (jointType.equals(aliases.pulleyJoint)) { PulleyJointDef pulleyJointDef = new PulleyJointDef(); assignProperties(pulleyJointDef, heritage); assignProperties(pulleyJointDef, mapProperties); assignProperties(pulleyJointDef, layerProperties); assignProperties(pulleyJointDef, properties); jointDef = pulleyJointDef; } else if (jointType.equals(aliases.revoluteJoint)) { RevoluteJointDef revoluteJointDef = new RevoluteJointDef(); assignProperties(revoluteJointDef, heritage); assignProperties(revoluteJointDef, mapProperties); assignProperties(revoluteJointDef, layerProperties); assignProperties(revoluteJointDef, properties); jointDef = revoluteJointDef; } else if (jointType.equals(aliases.ropeJoint)) { RopeJointDef ropeJointDef = new RopeJointDef(); assignProperties(ropeJointDef, heritage); assignProperties(ropeJointDef, mapProperties); assignProperties(ropeJointDef, layerProperties); assignProperties(ropeJointDef, properties); jointDef = ropeJointDef; } else if (jointType.equals(aliases.weldJoint)) { WeldJointDef weldJointDef = new WeldJointDef(); assignProperties(weldJointDef, heritage); assignProperties(weldJointDef, mapProperties); assignProperties(weldJointDef, layerProperties); assignProperties(weldJointDef, properties); jointDef = weldJointDef; } else if (jointType.equals(aliases.wheelJoint)) { WheelJointDef wheelJointDef = new WheelJointDef(); assignProperties(wheelJointDef, heritage); assignProperties(wheelJointDef, mapProperties); assignProperties(wheelJointDef, layerProperties); assignProperties(wheelJointDef, properties); jointDef = wheelJointDef; } else throw new IllegalArgumentException(JointType.class.getSimpleName() + " " + jointType + " is unknown"); assignProperties(jointDef, properties); Joint joint = jointDef.bodyA.getWorld().createJoint(jointDef); joint.setUserData(getProperty(properties, aliases.userData, joint.getUserData())); joints.put(findAvailableName(mapObject.getName(), joints), joint); listener.created(joint, mapObject); return joint; }
From source file:net.dermetfan.utils.libgdx.box2d.Box2DMapObjectParser.java
License:Apache License
/** creates a {@link Joint} from a {@link MapObject} * @param mapObject the {@link Joint} to parse * @return the parsed {@link Joint} */ public Joint createJoint(MapObject mapObject) { MapProperties properties = mapObject.getProperties(); JointDef jointDef = null;/*from w w w. j a v a2 s. c o m*/ String jointType = getProperty(properties, aliases.jointType, ""); if (jointType.equals(aliases.distanceJoint)) { DistanceJointDef distanceJointDef = new DistanceJointDef(); assignProperties(distanceJointDef, heritage); assignProperties(distanceJointDef, mapProperties); assignProperties(distanceJointDef, layerProperties); assignProperties(distanceJointDef, properties); jointDef = distanceJointDef; } else if (jointType.equals(aliases.frictionJoint)) { FrictionJointDef frictionJointDef = new FrictionJointDef(); assignProperties(frictionJointDef, heritage); assignProperties(frictionJointDef, mapProperties); assignProperties(frictionJointDef, layerProperties); assignProperties(frictionJointDef, properties); jointDef = frictionJointDef; } else if (jointType.equals(aliases.gearJoint)) { GearJointDef gearJointDef = new GearJointDef(); assignProperties(gearJointDef, heritage); assignProperties(gearJointDef, mapProperties); assignProperties(gearJointDef, layerProperties); assignProperties(gearJointDef, properties); jointDef = gearJointDef; } else if (jointType.equals(aliases.mouseJoint)) { MouseJointDef mouseJointDef = new MouseJointDef(); assignProperties(mouseJointDef, heritage); assignProperties(mouseJointDef, mapProperties); assignProperties(mouseJointDef, layerProperties); assignProperties(mouseJointDef, properties); jointDef = mouseJointDef; } else if (jointType.equals(aliases.prismaticJoint)) { PrismaticJointDef prismaticJointDef = new PrismaticJointDef(); assignProperties(prismaticJointDef, heritage); assignProperties(prismaticJointDef, mapProperties); assignProperties(prismaticJointDef, layerProperties); assignProperties(prismaticJointDef, properties); jointDef = prismaticJointDef; } else if (jointType.equals(aliases.pulleyJoint)) { PulleyJointDef pulleyJointDef = new PulleyJointDef(); assignProperties(pulleyJointDef, heritage); assignProperties(pulleyJointDef, mapProperties); assignProperties(pulleyJointDef, layerProperties); assignProperties(pulleyJointDef, properties); jointDef = pulleyJointDef; } else if (jointType.equals(aliases.revoluteJoint)) { RevoluteJointDef revoluteJointDef = new RevoluteJointDef(); assignProperties(revoluteJointDef, heritage); assignProperties(revoluteJointDef, mapProperties); assignProperties(revoluteJointDef, layerProperties); assignProperties(revoluteJointDef, properties); jointDef = revoluteJointDef; } else if (jointType.equals(aliases.ropeJoint)) { RopeJointDef ropeJointDef = new RopeJointDef(); assignProperties(ropeJointDef, heritage); assignProperties(ropeJointDef, mapProperties); assignProperties(ropeJointDef, layerProperties); assignProperties(ropeJointDef, properties); jointDef = ropeJointDef; } else if (jointType.equals(aliases.weldJoint)) { WeldJointDef weldJointDef = new WeldJointDef(); assignProperties(weldJointDef, heritage); assignProperties(weldJointDef, mapProperties); assignProperties(weldJointDef, layerProperties); assignProperties(weldJointDef, properties); jointDef = weldJointDef; } else if (jointType.equals(aliases.wheelJoint)) { WheelJointDef wheelJointDef = new WheelJointDef(); assignProperties(wheelJointDef, heritage); assignProperties(wheelJointDef, mapProperties); assignProperties(wheelJointDef, layerProperties); assignProperties(wheelJointDef, properties); jointDef = wheelJointDef; } jointDef.bodyA = bodies.get(getProperty(properties, aliases.bodyA, "")); jointDef.bodyB = bodies.get(getProperty(properties, aliases.bodyB, "")); jointDef.collideConnected = getProperty(properties, aliases.collideConnected, jointDef.collideConnected); Joint joint = jointDef.bodyA.getWorld().createJoint(jointDef); joint.setUserData(getProperty(properties, aliases.userData, joint.getUserData())); joints.put(findAvailableName(mapObject.getName(), joints), joint); return joint; }