I'm working on a cocos2d project in Xcode and I've been trying to get collision detection to work for weeks. I've been using the Ray Wenderlich tutorials which said to use a contact listener to detect collision. However, I get the error Invalid operands to binary expression ('const MyContact' and 'const MyContact'). I have never seen this error, can anyone help with this?
#import "MyContactListener.h"
MyContactListener::MyContactListener() : _contacts() {
}
MyContactListener::~MyContactListener() {
}
void MyContactListener::BeginContact(b2Contact* contact) {
MyContact myContact = { contact->GetFixtureA(), contact->GetFixtureB() };
_contacts.insert(myContact); <------------//Says "7.In instantiation of member function 'std::set<MyContact, std::less<MyContact>, std::allocator<MyContact> >::insert' requested here"
}
void MyContactListener::EndContact(b2Contact* contact) {
MyContact myContact = { contact->GetFixtureA(), contact->GetFixtureB() };
std::set<MyContact>::iterator pos;
pos = std::find(_contacts.begin(), _contacts.end(), myContact);
if (pos != _contacts.end()) {
_contacts.erase(pos);
}
}
void MyContactListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold) {
}
void MyContctListener::PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) {
}