C++ 围绕对象中心的SFML旋转
我这里有一个代码:C++ 围绕对象中心的SFML旋转,c++,sfml,C++,Sfml,我这里有一个代码: 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
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);
}
void Star::createStar(){
sf::圆形星1(r,50);
star1.设定位置(x,y);
sf::Texture*t=CreateTexture(256256);
star1.setTexture(t,false);
星=星1;
这是正确的代码
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);
}
void Star::createStar(){
sf::圆形星1(r,50);
star1.设定位置(x,y);
sf::Texture*t=CreateTexture(256256);
star1.setTexture(t,false);
星=星1;
std::请提交您的解决方案并选择正确的解决方案。