0
Xcode에서 cocos2d 프로젝트를 진행하고 있으며 충돌 감지가 몇 주 동안 작동하도록 노력했습니다. 나는 충돌 리커버리 (contact listener)를 사용하여 충돌을 감지했다는 Ray Wenderlich 자습서를 사용 해왔다. 그러나 오류가 발생했습니다 이진 표현식에 대한 잘못된 피연산자 ('const MyContact'및 'const MyContact'). 나는이 오류를 본 적이 없으며, 누구도이 문제를 도와 줄 수 있습니까?box2d 연락처 리스너의 의미 문제
#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) {
}
감사! 나는 이것에 상당히 새롭다, 그래서 정확하게 비교 연산자를 어디에 두는가? 내가 찾고있어하지만 내 코드에 맞는이 볼 수 없습니다 – evanlws
@eeveeayen : 내가 쓴 것처럼, MyContact 클래스 내부/구조체 – Andrew