Pergunta

I have problem. I have main.cpp file , where is main game, and few header files like CPlayer.h containing classes. In this classes I have animations, and I used enum to replace current animation number with current animation name like:

Class CPlayer
{
public:
Animation A[2];
int currAnim;

enum animationTitle
{
WALK,
ATTACK,
DESTROY
};
...
}

and I import this class to main. Then I cant do:

player.currAnim = ATTACK;

because enum is in header file. In CPlayer.h this enum works.

Only this works:

player.currAnim = 1;

Is there any way to get around this or I have to add this enum also to main.cpp? I don't want to have hundreds of enums in my main.cpp...(for every object, character...)

Thanks

Foi útil?

Solução

Then I cant do... because enum is in header file

Not true. It doesn't work because the correct syntax would be:

player.currAnim = CPlayer::ATTACK;

You defined the enum inside of your class. Why? Not sure, but that's what you did.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top