所以我在这里有这个代码:
void Star::createStar(){
sf::CircleShape star1(r,50);
star1.setPosition(x,y);
sf::Texture* t = CreateTexture(256,256);
star1.setTexture(t,false);
star=star1;
std::cout << "Done!"<<std::endl;
}
void Star::update(){
star.setOrigin(x-(.5*r),y-(.5*r));
star.rotate(0.01);
}
我希望恒星围绕它的中心旋转,但我可能在计算错误,但它似乎围绕着相同的点旋转,即使我没有声明中心也是如此。
编辑::我修复了它star.setOrigin()应该是arameters r,r!
答案 0 :(得分:2)
这是正确的代码
void Star::createStar(){
sf::CircleShape star1(r,50);
star1.setPosition(x,y);
sf::Texture* t = CreateTexture(256,256);
star1.setTexture(t,false);
star=star1;
std::cout << "Done!"<<std::endl;
}
void Star::update(){
//star.setOrigin(x-(.5*r),y-(.5*r));
//no need to set origin
star.rotate(0.01);
}