1
我试图让这个C++方法在我的iOS游戏中工作。不明白这些C++ box2d错误
-(b2Vec2) RayCheckWithInput:p1 andX:p2
{
b2RayCastInput input;
input.p1 = p1;
input.p2 = p2;
input.maxFraction = 1;
//check every fixture of every body to find closest
float closestFraction = 1; //start with end of line as p2
b2Vec2 intersectionNormal(0,0);
for (b2Body* b = self.world.world->GetBodyList(); b; b = b->GetNext()) {
for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext()) {
b2RayCastOutput output;
if (! f->RayCast(&output, input))
continue;
if (output.fraction < closestFraction) {
closestFraction = output.fraction;
intersectionNormal = output.normal;
}
}
}
b2Vec2 intersectionPoint = p1 + closestFraction * (p2 - p1);
return intersectionPoint;
}
我知道一些关于obj-c的知识,但不是C++。以下是它显示的该方法的错误屏幕截图。
任何帮助表示赞赏(在Chrome中,你可以做右键打开图像在新标签中看到它更好)
p1和p2只是点的向量,不确定C++中的类型是什么? – Phil 2014-10-05 18:08:55
我不确定childIndex应该是什么,但它解决了错误,谢谢:) – Phil 2014-10-05 18:17:30