bastienleonard / pysfml-cython

A Python 2/3 binding for SFML 2, written with Cython
http://pysfml2-cython.readthedocs.org/
Other
68 stars 8 forks source link

Sprite.set_texture_rect set to read only #40

Closed pygg2devs closed 12 years ago

pygg2devs commented 12 years ago

it seems that you cannot modify/set the texture coordinates of a texture of a sprite, since that method was introduced in pysfml 0.13

I am running Win7/64bit.

bastienleonard commented 12 years ago

Before 0.1.3, you need to use Sprite.texture_rect. The problem it had is that texture_rect's getter returned a copy, and that was confusing for a property, e.g. sprite.texture_rect.top = 3 wouldn't work as expected. (get_texture_rect() still returns a copy, by the way.)

nagn commented 12 years ago

but set_texture_rect should still be able to be used to assign which region of a texture a sprite is, correct?

bastienleonard commented 12 years ago

Before 0.1.3? It wasn't available back then, you had to use Sprite.texture_rect. If you use texture rects, there is no way to write code that is compatible with e.g. 0.1.2 and 0.1.3 (unless you find the right attribute with hasattr and then use it, but it's overkill). Is this what you're asking?

nagn commented 12 years ago

but python keeps complaining that set_texture_rect is set to read only.

The following code does not work sprite = sfml.Sprite(self.texture) sprite.set_texture_rect = sfml.IntRect(0, 0, 9, 13)

bastienleonard commented 12 years ago

You need to pass the rect as an argument:

sprite.set_texture_rect(sfml.IntRect(0, 0, 9, 13))
nagn commented 12 years ago

... i'm stupid