SFML community forums

Help => Graphics => Topic started by: ShadowDancer on January 01, 2010, 03:31:55 pm

Title: Scaled Tiles
Post by: ShadowDancer on January 01, 2010, 03:31:55 pm
What will be best way to solve my problem? I tried

Code: [Select]

float Scale = Tileset.GetHeight() * 1.0f /Field_Size ;
sf::IntRect Rect((Element_Type*Tileset.GetHeight()) * Scale, 0, (Tileset.GetHeight()) * Scale, (Tileset.GetHeight())*Scale);
Tileset_Sprite.SetScale(Scale,Scale);Tileset_Sprite.SetSubRect(Rect);Tileset_Sprite.SetPosition(Field_Pos_X, Field_Pos_Y);
Render->Draw(Tileset_Sprite);


But it don't works.

Maybe is possible to make sprite from part of another sprite, but I don't found it. Any suggestions?
Title: Scaled Tiles
Post by: Nexus on January 01, 2010, 04:51:12 pm
What do you exactly want to achieve? Express it in words, not code.
Title: Scaled Tiles
Post by: ShadowDancer on January 01, 2010, 05:26:44 pm
I want get scaled tile on my screen.

Edit. I forgot Imag.Copy. Sorry for making problems.
Title: Scaled Tiles
Post by: Laurent on January 01, 2010, 06:46:54 pm
To scale a sprite just use SetScale.
Title: Scaled Tiles
Post by: Nexus on January 02, 2010, 12:54:01 am
Quote from: "ShadowDancer"
Edit. I forgot Imag.Copy. Sorry for making problems.
What does sf::Image::Copy() have to do with this issue? You needn't edit the source image to scale your tiles, but the sprite.