Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Rope {
- private World world;
- private DistanceJoint rope;
- private boolean ropeExists = false;
- public Rope(World world){
- this.world = world;
- }
- public void createRope(Body player, Body cloud){
- destroyRope();
- DistanceJointDef dDef = new DistanceJointDef();
- dDef.initialize(player, cloud, player.getPosition(), cloud.getPosition());
- if(!world.isLocked()) {
- rope = (DistanceJoint) this.world.createJoint(dDef);
- }
- ropeExists = true;
- }
- public void destroyRope(){
- if(ropeExists && !world.isLocked()) {
- this.world.destroyJoint(rope);
- rope = null;
- ropeExists = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement