SFML community forums

Bindings - other languages => Python => Topic started by: gaulois94 on July 10, 2013, 09:52:34 pm

Title: [Solved] sf.Vector2(sf.Vector2) create some problems
Post by: gaulois94 on July 10, 2013, 09:52:34 pm
Hi . I'm post today for saying that if you do newVector = sf.Vector2(vector) where vector is a sf.Vector2 too, then newVector.x is a sf.Vector2 and newVector.y = 0. Can we have a constructor who do a copy of the first sf.Vector2 ? Thank you :) .
Title: Re: sf.Vector2(sf.Vector2) create some problems
Post by: Sonkun on July 12, 2013, 04:52:45 pm
The sf.Vector2 constructor takes x and y, the two being optional and defaulted to 0. So if you write sf.Vector2(a) with a being a sf.Vector2, you'll get a as x. What you need to do is, unpacking a.

x, y = a
newVector = sf.Vector2(x, y)

Or shorter:

newVector = sf.Vector2(*a)

Good luck! :)
Title: Re: sf.Vector2(sf.Vector2) create some problems
Post by: gaulois94 on July 13, 2013, 12:11:29 am
Thanks :) . I do it many times because I need to copy the vector (for not modifie the first).