【发布时间】:2011-04-14 17:26:53
【问题描述】:
这个for循环在绘制多个相同对象时遇到了一些问题,
for (int i = BALL_RED_START; i<BALL_RED_END;i++)
{
glColor3f(1,0,0);
Redball[i].Draw();
}
Redball 正在从一个单独的类中调用,
I get error:2228, left of .Draw must have class/struct/union.
Redball 定义在 Main.cpp 的顶部
Ball Redball;
球.cpp:
include "Ball.h"
include "Vector2f.h"
include "Vector3f.h"
include "Glut/glut.h"
include "GL/gl.h"
include "GL/glu.h"
Ball::Ball(void)
{
Vector3f Temp_position;
position = Temp_position;
Vector3f Temp_velocity;
velocity = Temp_velocity;
}
Ball::~Ball(void)
{
}
void Ball::SetPos(Vector3f New_position)
{
position = New_position;
}
void Ball::Draw()
{
glPushMatrix();
glTranslatef(position.X(), position.Y(), position.Z());
glColor3d(1, 0, 0);
glutSolidSphere(0.3, 50, 50);
glPopMatrix();
}
void Ball::SetVel(Vector3f New_velocity)
{
velocity = New_velocity;
}
Vector3f Ball::GetPos()
{
Vector3f temp;
temp = position;
return temp;
}
只是想抽出 8 个这样的球。
【问题讨论】:
-
你不认为我们想知道.Draw 的左边是什么?我的朋友,红球是如何被宣布的?
-
我试过了 -> 到目前为止没有运气!
-
当您有更多信息时,也许可以在my answer 上给我留言,我不必经常回来查看