2013-06-26 61 views
1

所以我有這樣的代碼在這裏: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(x-(.5*r),y-(.5*r)); 

star.rotate(0.01); 
} 

,我想明星以圍繞它的中心,但我可能是做算盤打錯了,但它似乎繞即使我沒有宣佈中心也是如此。

編輯::我固定它的star.setOrigin()應haev arameters R,R!

+0

請提交您的解決方案,並選擇它是正確的。 – DCurro

回答

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); 
}