How to create a line that is always connected to two Objects. (iPhone, Cocos2d)

I'm wanting to create a rope like animation effect. I don't need any kind of rope physics, all I need is a straight line connected to Object A and the other end connected to object B. Object A and B move relative to one another. So how do I make it so that the line is always attached to both Objects, even thought the distance between the objects decrease and increase?

The game is in 2D space.

• You say it only needs to be straight while also saying it needs to contract and expand. Which is it? Commented Jan 15, 2015 at 10:39
• It only needs to be straight in the sense that it doesn't bend and is straight like an arrow. When is said contract and expand I meant it follows the harpoon as it goes up and down, but it isn't actually contracting and expanding, it just looks like it. Trying to make it simple: have you played the game goldminer? Thats what I need. A rope that acts like that rope, which is just a straight line that follows the claw object. Commented Jan 15, 2015 at 15:57
• So what are you trying and where are you getting stuck? Because it sounds like literally all you need is a black line. Commented Jan 16, 2015 at 23:42
• Yes, a black or preferably a brown line that is connected to object A and object B at all time. Even thought A and B move relative to one another in 2D space (Sideways & Up/Down). So I don't know how to keep the line connected to both A and B at all times, thats where I get stuck. Commented Jan 17, 2015 at 10:49
• You know what, I'll rephrase my question for simplicity. Commented Jan 17, 2015 at 11:15

Point start = objectA.position