Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problems rotating sprites  (Read 2242 times)

0 Members and 1 Guest are viewing this topic.

rensu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Problems rotating sprites
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problems rotating sprites
« Reply #1 on: March 26, 2009, 08:03:19 pm »
Code: [Select]
sprite.SetCenter(sprite.GetSize() / 2.f);
Laurent Gomila - SFML developer

rensu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Problems rotating sprites
« Reply #2 on: March 26, 2009, 08:22:46 pm »
thanks very much :)

just out of interest what does the  2.f mean?

Core Xii

  • Jr. Member
  • **
  • Posts: 54
    • MSN Messenger - corexii@gmail.com
    • AOL Instant Messenger - Core+Xii
    • View Profile
Problems rotating sprites
« Reply #3 on: March 26, 2009, 08:33:38 pm »
it's a floating point number, 2.0 in value.

 

anything