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

Author Topic: Scale a Sprite to fit a whole window?  (Read 2234 times)

0 Members and 1 Guest are viewing this topic.

Austech

  • Newbie
  • *
  • Posts: 23
    • View Profile
Scale a Sprite to fit a whole window?
« on: February 01, 2010, 09:52:19 am »
Is there a mathematical way to scale a sprite to fit a whole window? I tried scaling it like:

Scale(WindowWidth - ImageWidth,WindowHeight - ImageHeight);

But It seems to scale way too big. So is there a way to do it?

Once again thanks in advanced.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Scale a Sprite to fit a whole window?
« Reply #1 on: February 01, 2010, 10:06:23 am »
The scale is a factor that it multiplied to the original size, not added. So you should call
Code: [Select]
sprite.Scale(WindowWidth / ImageWidth, WindowHeight / ImageHeight);
Or simply use Resize, which does this job for you
Code: [Select]
sprite.Resize(WindowWidth, WindowHeight);
Laurent Gomila - SFML developer

Austech

  • Newbie
  • *
  • Posts: 23
    • View Profile
Scale a Sprite to fit a whole window?
« Reply #2 on: February 01, 2010, 10:34:05 am »
Thanks, the resize function worked perfectly.  :)

 

anything