I get 5 errors at the following snippet of code
4 of the errors are
expected unqualified-id before '(' token|
and 1 error
'GetEntityIterator' was not declared in this scope|
GetEntityIterator()
returns vector<*Entity>::iterator EntityIterator
GetAABB()
returns an AABB
I can post more code if needed
void Bomb::CreateExplosion(Game_Manager* EGame_Manager)
{
BombTexture->LoadTexture("Bomb.bmp");
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
for(int iteration = 1; iteration <= 3; iteration++)
{
if(this->GetAABB()->CheckForCollision(this->GetAABB(), EGame_Manager->getEntityManager()->(*GetEntityIterator())->GetAABB()) == true)//check for collision against the unbreakable blocks or player and does what is necessary for each
{
if(EGame_Manager->getEntityManager()->(*GetEntityIterator())->GetType() == unbreakableblock)
{
break;
}
else if(EGame_Manager->getEntityManager()->(*GetEntityIterator())->GetType() == player)
{
EGame_Manager->getEntityManager()->(*GetEntityIterator())->GetLives() -= 1;
}
}
else
glBegin(GL_QUADS);
glColor4f( 1.0f, 0.0f, 0.0f, 0.0f); //color red
glTexCoord2f(0.0, 0.0); //uv coordinates
glVertex3f( -2.0f + x,2.0f + y, 0.0f); //top left
//----------------------------------------------------
开发者_开发问答 glColor4f( 0.0f, 1.0f, 0.0f, 0.0f); //color green
glTexCoord2f(1, 0.0 ); //uv coordinates
glVertex3f( 2.0f + x,2.0f + y, 0.0f); //top right
//----------------------------------------------------
glColor4f( 0.0f, 0.0f, 1.0f, 0.0f); //color blue
glTexCoord2f(1, 1);
glVertex3f( 2.0f + x, -2.0f + y, 0.0f); //bottom right
//----------------------------------------------------
glColor4f( 1.0f, 1.0f, 0.0f, 0.0f); //color red
glTexCoord2f(0.0, 1); //uv coordinates
glVertex3f(-2.0f + x, -2.0f + y, 0.0f); //bottom left
glEnd();
}
glDisable(GL_TEXTURE_2D); //disable 2d textures
}
Maybe because of this syntax:
getEntityManager()->(*GetEntityIterator())
?
I'm not sure what you were trying to do, but the ->
operator is supposed to be followed by the name of a member of the class.
Edit
After reading iaamilind's comment, I finally think I understand what you were trying to do. You were trying to dereference the iterator, but then you still had to dereference the pointer (Entity*
) it returned, so the ->
operator was not enough. You're correct that you have to use parentheses and the *
operator - but you've put them in the wrong place. This is what you should do:
(*EGame_Manager->getEntityManager()->GetEntityIterator())->GetType()
From your code it looks that GetEntityIterator()
returns pointer. Try changing it to,
GetEntityIterator()
(i.e. remove the pointer *
ahead of it). e.g.
EGame_Manager->getEntityManager()->GetEntityIterator()->GetType();
Also make sure that such function is declared/defined in the class.
精彩评论