public void drawSelf(String score, int texId) // 传入数字和纹理坐标 { scoreStr = score; MatrixState.pushMatrix(); MatrixState.translate(-scoreStr.length() * width, 0, 0); for (int i = 0; i < scoreStr.length(); i++) // 将得分中的每个数字字符绘制 { char c = scoreStr.charAt(i); MatrixState.translate(width, 0, 0); number[c - '0'].drawSelf(texId); } MatrixState.popMatrix(); }
// 总的绘制方法drawSelf public void drawSelf(int texId) { // 绘制交通柱的圆柱部分 cone_in.drawSelf(texId); // 绘制交通柱下方底座的上面 MatrixState.pushMatrix(); MatrixState.translate(0, -UNIT_SIZE, 0); pedestal.drawSelf(texId); MatrixState.popMatrix(); // 绘制交通柱下方底座的侧面 MatrixState.pushMatrix(); MatrixState.translate(0, -UNIT_SIZE - HEIGHT, 0); cylinder.drawSelf(texId); MatrixState.popMatrix(); // 绘制交通柱下方底座的下面 MatrixState.pushMatrix(); MatrixState.translate(0, -UNIT_SIZE - HEIGHT * 2, 0); MatrixState.rotate(180, 1, 0, 0); pedestal.drawSelf(texId); MatrixState.popMatrix(); }