I am trying to write a very basic game for my first SFML project. Its a robot with a jointed arm that will be able to pop balloons with his hand only. The problem I am having is that when checking to see if the pincer sprite intersects with the balloon sprite , it returns true all the time, regardless of the placement of the balloon or the robot pincer. I am using transform to place the various parts of the robot arm, and this is whats causing the problem I think, but I don't know why. I have tried using bounding box collision in a separate program where transform is not used and it worked perfectly. The transformation and detection code is below. I am brand new to SFML so apologies for my ignorance here!!
sf::Transform trBody;
trBody.translate(sBodyPos);
/////////////////////////////////////////////////
sf::Transform trArm1;
trArm1.translate(sArm1Pos);
sf::Transform rotArm1;
rotArm1.rotate(sArm1Rot);
sf::Transform TR1 = trBody*trArm1*rotArm1;
/////////////////////////////////////////////////
sf::Transform trArm2;
trArm2.translate(sArm2Pos);
sf::Transform rotArm2;
rotArm2.rotate(sArm2Rot);
sf::Transform TR2 = TR1*trArm2*rotArm2;
/////////////////////////////////////////////////
sf::Transform trPincer1;
trPincer1.translate(sPincer1Pos);
sf::Transform TR3 = TR2*trPincer1;
/////////////////////////////////////////////////
sf::Transform trPincer2;
trPincer2.translate(sPincer2Pos);
sf::Transform TR4 = TR2*trPincer2;
/////////////////////////////////////////////////
sf::Transform trBalloon1;
trBalloon1.translate(sBalloon1Pos);
if (sPincer1.getGlobalBounds().intersects(sBalloon1.getGlobalBounds())){
cout << "Bang" << endl;
ballOneHit = true;
}
// Clear screen
app.clear();
app.draw(sArm2, TR2);
app.draw(sPincer1, TR3);
app.draw(sPincer2, TR4);
app.draw(sArm1, TR1);
app.draw(sBody, trBody);
if (ballOneHit == false){
app.draw(sBalloon1, trBalloon1);
}
// Update the window
app.display();