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

Author Topic: [Solved] Sprite.position.x/y read-only? Yes :(  (Read 6272 times)

0 Members and 1 Guest are viewing this topic.

PythonFanboy

  • Newbie
  • *
  • Posts: 5
    • View Profile
[Solved] Sprite.position.x/y read-only? Yes :(
« on: November 02, 2013, 09:17:34 pm »
I can't move a sprite, changes to Sprite.position.x/y are ignored. I'm doing something wrong or this is a bug in pySFML?

In [1]: import sfml

In [2]: texture = sfml.Texture.from_file('fire.png')

In [3]: sprite = sfml.Sprite(texture)

In [4]: sprite.position
Out[4]: sf.Vector2(0.0x, 0.0y)

In [5]: sprite.position.x = 300  # Doesn't work?

In [6]: sprite.position
Out[6]: sf.Vector2(0.0x, 0.0y)

I'm using Python 3.3, SFML 2.0 and pySFML 1.3.
« Last Edit: November 03, 2013, 08:37:31 pm by PythonFanboy »

Tljjz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Sprite.position read-only?
« Reply #1 on: November 02, 2013, 09:55:35 pm »
It works if you write it like this:
sprite.position = (300, sprite.position.y)

Most likely sprite.position.x decodes the x coordinate from the sf.Transform (sf.Sprite inherits sf.Transformable which is a wrapper around sf.Transform) and returns it. So it's not a bug in pySFML, but simply the way SFML works.

PythonFanboy

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Sprite.position.x/y read-only?
« Reply #2 on: November 03, 2013, 12:05:53 pm »
Thanks for the info!

 

anything