Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Graphics
»
Stretch Sprite/Texture
Print
Pages: [
1
]
Author
Topic: Stretch Sprite/Texture (Read 7696 times)
0 Members and 1 Guest are viewing this topic.
aaroncm
Newbie
Posts: 20
Stretch Sprite/Texture
«
on:
January 14, 2013, 07:49:45 am »
Hey, I can't find the answer to this anywhere (Well I could but not for 2.0)
How do I simply stretch a, say, 100x100 image to 1024x768.
sf::Texture/Sprites have no setSize() functions so I'm not sure, does it have something to do with views?
Thanks.
Logged
Nexus
SFML Team
Hero Member
Posts: 6287
Thor Developer
Re: Stretch Sprite/Texture
«
Reply #1 on:
January 14, 2013, 07:54:11 am »
sf::Sprite::setScale()
You have to calculate a little bit. The sprite's size can be retrieved from the rectangle
sf::Sprite::getLocalBounds()
.
Logged
Zloxx II
: action platformer
Thor Library
: particle systems, animations, dot products, ...
SFML Game Development
:
aaroncm
Newbie
Posts: 20
Re: Stretch Sprite/Texture
«
Reply #2 on:
January 14, 2013, 08:04:06 am »
Hmm what sort of calculation? I've tried setScale but it seems to stretch the image way beyond the size I'm specifying. But I also can't seem to find any documentation of setScale for 2.0 either, so I'm not sure what it's doing.
Any ideas?
Thanks
Logged
awsumpwner27
Newbie
Posts: 27
Re: Stretch Sprite/Texture
«
Reply #3 on:
January 14, 2013, 08:20:13 am »
http://www.sfml-dev.org/documentation/2.0/classsf_1_1Sprite.php#a4c48a87f1626047e448f9c1a68ff167e
There's where it is in the documentation.
If it helps (because the documentation never fully explains), you can get a number to give Sprite::setScale() if you ask yourself this question:
What do I need to multiply 100x100 by to get 1024x768? Which really means: What's 1024/100, and 768/100? The result will be 10.24 and 7.68, which are the values you can give setScale in this case.
Logged
aaroncm
Newbie
Posts: 20
Re: Stretch Sprite/Texture
«
Reply #4 on:
January 14, 2013, 08:33:16 am »
Thanks guys, all working now
Logged
Print
Pages: [
1
]
SFML community forums
»
Help
»
Graphics
»
Stretch Sprite/Texture