SFML community forums

Help => Graphics => Topic started by: hakeris1010 on September 08, 2014, 04:48:10 pm

Title: Set size of the sprtite
Post by: hakeris1010 on September 08, 2014, 04:48:10 pm
Hello! I need to set the the specific size of the sprite. SetScale() is not a solution there, because sprite may come in unknown dimensions, and program must resize it to lets say 160x100. What to do???
Title: Re: Set size of the sprtite
Post by: G. on September 08, 2014, 04:56:44 pm
scaleX is wantedX / currentX
scaleY is wantedY / currentY
If you don't care about the size ratio of your sprite, just setScale(scaleX, scaleY)
If you want it to keep the same ratio, use the minimum scale for x and y, setScale(min(scaleX, scaleY), min(scaleX, scaleY))