hello every one
I want to create class cannon which is a class to simulate a real cannon
the cannon is represented by a rectangle shape
I want this rectangle to always work in relative transforms
the owner of the cannon must pass it's sf::transformable part of it in the constructor
and in the class i keep a reference to this sf::transformable
i think this should work but it is not
here a small program that do this ((not the real one the real one is a failure )) and it's not working as expected
void main(){
sf::RenderWindow window (sf::VideoMode(400,400),"cannon test 1");
sf::RectangleShape ret(sf::Vector2f(30,30));
ret.setPosition(200,200);
sf::CircleShape circle(30);
circle.setOrigin(30,30);
circle.setPosition(0,0);
sf::Transformable &ref = ret;
while(true)
{
sf::Event event;
while(window.pollEvent(event)){}
sf::Transform tra =sf::Transform::Identity ;
tra.combine(ref.getTransform());
tra.combine(circle.getTransform());
window.clear();
window.draw(ret);
window.draw(circle,tra);
window.display();
}
}
here the result