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

Author Topic: problem with scaling  (Read 1706 times)

0 Members and 1 Guest are viewing this topic.

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
problem with scaling
« on: October 06, 2008, 09:29:11 pm »
well i hope u can answer this:

i have a class shooter;

Code: [Select]
class shooter
{
...
protected:
   
    unsigned int width;                
    unsigned int height;
    static sf::Image Image;            
    sf::Sprite Sprite;
public :
    void scale(float x, flaot y);
}


when my object is created, width and height are taken from its image:

Code: [Select]
shooter::shooter()  
{
    Sprite.SetImage(Image); // every sprite uses the same unique image
    width    = Image.GetWidth();
    height   = Image.GetHeight();
    Position = Sprite.GetPosition();
}

when it´s scaled the sprite should be scaled AND width and height should be re-calculated, what i tried like this:

Code: [Select]
void shooter::Scale(float x, float y)
{
    Sprite.Scale(x,y);
    width = width * x;
    height= height * y;
}

i tried it, but when i let my program write width and height i have a problem; it´s not always correct;

whats the mistake in my code?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
problem with scaling
« Reply #1 on: October 07, 2008, 07:43:43 am »
It should be correct. But why don't you just call GetWidth() and GetHeight() instead of applying the scale manually ?
Laurent Gomila - SFML developer