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

Author Topic: texture rectangle not working  (Read 6555 times)

0 Members and 1 Guest are viewing this topic.

grim

  • Guest
texture rectangle not working
« on: November 26, 2014, 08:29:30 am »
The pysfml site didn't really have anything that showed this being used and looking at the C++ version didn't really help either.  What I'm trying to do is draw a full progress bar onto the screen but have the texture rectangle set to only show part of it to represent what data has been loaded.  What I have right now is this:
self.loadBar.texture_rectangle = sf.Rectangle((0,0),(relativeSize, 20))
But it doesn't work, it still shows the whole thing.  Am I not using it right?

PixelGordo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: texture rectangle not working
« Reply #1 on: November 26, 2014, 11:03:54 pm »
(Sorry for not being able to provide now a full working example.)

What I do:

o_texture = sfml.Texture.from_file(s_file)                       # Full image texture loaded from disk
o_sprite = sfml.Sprite(o_texture)                                # Creating a sprite from the texture
o_sprite.texture_rectangle = sfml.Rectangle((10, 10), (50, 30))  # "cropping" only the rectangle I want from the full texture

Of course this is a basic example and you should do it with proper coding to keep your texture "alive".

Hope it helps.

grim

  • Guest
Re: texture rectangle not working
« Reply #2 on: November 27, 2014, 03:54:49 am »
LoadBar is a rectangle shape. My texture is loaded in a resource manager. It loads the textire just fine, the problem is the texture rectangle isnt changing its size.

grim

  • Guest
Re: texture rectangle not working
« Reply #3 on: November 27, 2014, 05:52:44 pm »
I think I'm beginning to see what it's doing.  After playing with values in the texture_rectangle, it appears to just be taking what the texture rectangle is selecting and just stretching it out across the whole rectangle shape.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: texture rectangle not working
« Reply #4 on: November 27, 2014, 06:31:10 pm »
That's it indeed. ;)
Reduce the width of your rectangle shape.