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

Author Topic: [Solved] sf.Vector2(sf.Vector2) create some problems  (Read 6033 times)

0 Members and 2 Guests are viewing this topic.

gaulois94

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
[Solved] sf.Vector2(sf.Vector2) create some problems
« 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 :) .
« Last Edit: November 04, 2013, 10:12:00 am by Sonkun »

Sonkun

  • Moderator
  • Full Member
  • *****
  • Posts: 241
    • View Profile
Re: sf.Vector2(sf.Vector2) create some problems
« Reply #1 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! :)
Interested in using SFML with Python ? Try out its Python binding!

gaulois94

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: sf.Vector2(sf.Vector2) create some problems
« Reply #2 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).

 

anything