SFML community forums

Help => General => Topic started by: rensu on March 26, 2009, 07:09:00 pm

Title: Problems rotating sprites
Post by: rensu on March 26, 2009, 07:09:00 pm
Hey guys

basically I am attempting to rotate a sprite in a tile... i simply want the sprite to stay in its current position and rotate... BUT the sprite moves up a tile and rotates... when i press down to put the sprite back into its previous position it changes the objects y axis position by 1...

how can i rotate the sprite so that it stays at say coordniate 2,2 but rotates 90 degrees... when i rotate the sprite it appears to change to 2,1 but the object hasnt moved and still stays at 2,2 .

I know its something to do with setting the center of the sprite but i have tried a lot of different things and just cant it to work!

its a game like battleships in case your wondering

please some one help :p
Title: Problems rotating sprites
Post by: Laurent on March 26, 2009, 08:03:19 pm
Code: [Select]
sprite.SetCenter(sprite.GetSize() / 2.f);
Title: Problems rotating sprites
Post by: rensu on March 26, 2009, 08:22:46 pm
thanks very much :)

just out of interest what does the  2.f mean?
Title: Problems rotating sprites
Post by: Core Xii on March 26, 2009, 08:33:38 pm
it's a floating point number, 2.0 in value.