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

Author Topic: Color based collision detection,getColor() problem?!  (Read 3263 times)

0 Members and 1 Guest are viewing this topic.

  • Guest
Color based collision detection,getColor() problem?!
« on: September 11, 2010, 12:52:08 pm »
Hi, i'm a beginner , my problem is : i have two containers each having (sf::Shape) objects , my code is something like this:
Code: [Select]

//imagine two containers with iter1 is for container 1 and iter2 for the second
for(//traverse first container)
{
for(//traverse second container)
{
if((iter1->getColor() == iter2->getColor()) && (col_det(//pass)))
//do something
}
}


the collision detection works fine (simple circle method ) but the color part is not working, i.e. it collides regardless of the color.WHY?
please help me and remember i'm still a beginner and stupid.
thanks in advance.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Color based collision detection,getColor() problem?!
« Reply #1 on: September 11, 2010, 01:11:24 pm »
Remember that the color that you pass to the sf::Shape::Circle function is assigned to each points of the shape, and is different from the global color that you get with GetColor.
Laurent Gomila - SFML developer

  • Guest
Color based collision detection,getColor() problem?!
« Reply #2 on: September 11, 2010, 03:23:40 pm »
WOW :D thank you, it worked , i was passing the color to the constructor only , i must have used setColor function, thank you again :P

 

anything