我在我的游戏中自定义调试绘制物理形状。在我升级到 cocos2d 2.0、iOS 5 后,我遇到了一些错误,表明我需要替换 cccolor4f、glpushmatrix 等。但我找不到 glscalef 功能的替代品。我在此函数调用中遇到错误。
这是我的代码:
[super draw];
kmGLPushMatrix();
{
// No idea what will replace this one
// glScalef(PTM_RATIO, PTM_RATIO,0.f);
ccDrawColor4F(0.f, 1.f, 0.f, 1.f);
[physicsshapeobject debugdraw]; // This calls the function below for different shapes
}
kmGLPopMatrix();
ccDrawColor4F(1.f, 1.f, 0.f, 1.f);
ccPointSize(10.f);
//drawPoint(collisionAt_);
ccPointSize(1.f);
}
-(void) debugDraw{
if(polygonShape != NULL){
CGPoint boxPt = ccpFromB2Vec(shapeTransform->p, NO);
CGPoint p1 = ccpAdd(boxPt,ccpFromB2Vec(polygonShape->m_vertices[0], NO));
CGPoint p2 = ccpAdd(boxPt,ccpFromB2Vec(polygonShape->m_vertices[1], NO));
CGPoint p3 = ccpAdd(boxPt,ccpFromB2Vec(polygonShape->m_vertices[2], NO));
CGPoint p4 = ccpAdd(boxPt,ccpFromB2Vec(polygonShape->m_vertices[3], NO));
ccVertex2F v1;
ccVertex2F v2;
ccVertex2F v3;
ccVertex2F v4;
v1.x = p1.x;
v1.y = p1.y;
v2.x = p2.x;
v2.y = p2.y;
v3.x = p3.x;
v3.y = p3.y;
v4.x = p4.x;
v4.y = p4.y;
ccQuad2 quad = (ccQuad2){
v1,
v2,
v3,
v4,
};
ccDrawColor4F(1.f, 0.f, 0.f, 1.f);
ccDrawPoly((CGPoint*)&quad, 4, YES);
}
}
形状不绘制的原因可能是什么?cocos2d 2.0中glscalef的替代品是什么?
任何帮助表示赞赏!
谢谢