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

Author Topic: Multiple sprite-rotation  (Read 2202 times)

0 Members and 1 Guest are viewing this topic.

kafkadaffi

  • Newbie
  • *
  • Posts: 3
    • View Profile
Multiple sprite-rotation
« on: June 30, 2009, 03:35:48 am »
Hi I was wondering if there is any possible way of doing  the following...

Imagine that I have an object, that has a render method and that method
renders a matrix/grid of sprites. eg. 10 times 10 sprites.
Is it possible to rotate that grid in whole. I have tried to rotate each individual sprite with a proper offset and that just looks bananas.

I guess I would like to render the sprites to another sprite and then rotate that grouping sprite, but that is not possible. Is there any other way of doing this?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Multiple sprite-rotation
« Reply #1 on: June 30, 2009, 07:57:21 am »
Just put your grid of sprites into a class that inherits from sf::Drawable. Then all the transformations of this drawable will be combined with the sprites' ones.
Laurent Gomila - SFML developer

kafkadaffi

  • Newbie
  • *
  • Posts: 3
    • View Profile
Multiple sprite-rotation
« Reply #2 on: July 02, 2009, 08:22:03 am »
Are you sure? I must have done something wrong.

I have setup an Object that inherits from sf::Drawable and then I override the Render() method, where I render say two different sprites. Sofar sogood, I see the sprites being rendered ok.

But transformation on that Object containing those sprites does exactly nothing to my contained sprites. I have hard time to think how it can ever.

kafkadaffi

  • Newbie
  • *
  • Posts: 3
    • View Profile
Multiple sprite-rotation
« Reply #3 on: July 02, 2009, 08:30:19 am »
Ah, my Bad!
I called Render of the compositing sprite with the target as parameter instead of calling Draw(&Drawable ) passing a reference to the compositing sprite. Clearly there is a difference.

Code: [Select]
m_tSprite.Render(*m_pMainWindow);  // Renders without parent obj. Translations and etc.
m_pMainWindow->Draw(m_tSprite);    // Renders using translations and etc.


Now it works like a clockwork!   :lol:

Come to think of it, It was fully possible to override the protected virtual Render( ) with a public one exposing the method.

 

anything