このC++メソッドでb2Fixtureインスタンスの配列を返そうとしています。これは、次のように定義された一連のJRContactインスタンスを繰り返します。
struct JRContact {
b2Fixture *fixtureA;
b2Fixture *fixtureB;
bool operator==(const JRContact& other) const
{
return (fixtureA == other.fixtureA) && (fixtureB == other.fixtureB);
}
};
nb私はC++をまったく知らないので、そのコードで行った可能性のある奇妙なことについて言及することを躊躇しないでください;-)
以下はコンパイルに失敗します(MacOSのXCodeコンパイラ)。コメントのエラーを参照してください。
id AbstractContactListener::getFixturesOfTypeCollidingWithFixture(b2Fixture *fix, int type){
std::vector<b2Fixture> fixtures;
std::vector<JRContact>::iterator ct;
JRContact contact;
for (ct = _contacts.begin(); ct != _contacts.end(); ct++){
contact = *ct;
if (
( (fix == contact.fixtureA) || (fix == contact.fixtureB) ) &&
( contactContainsType(contact, type) )
){
if (fix == contact.fixtureA) {
// error: Semantic Issue: Reference to type 'const value_type' (aka 'const b2Fixture') could not bind to an lvalue of type 'b2Fixture *'
fixtures.push_back(contact.fixtureB);
}
else {
// error: Semantic Issue: Reference to type 'const value_type' (aka 'const b2Fixture') could not bind to an lvalue of type 'b2Fixture *'
fixtures.push_back(contact.fixtureA);
}
}
}
// error: Semantic Issue: No viable conversion from 'std::vector<b2Fixture>' to 'id'
return fixtures;
}
御時間ありがとうございます!