Error when updating enumerated value?
Posted
by
igrad
on Game Development
See other posts from Game Development
or by igrad
Published on 2014-06-03T01:13:56Z
Indexed on
2014/06/03
3:44 UTC
Read the original article
Hit count: 180
Once upon a time, there was a Player class
(simplified version)
enum animState{RUNNING,JUMPING,FALLING,IDLING};
class Player
{
public:
Player(int x, int y);
void handle();
void show();
~Player();
private:
int m_x;
int m_y;
animState playerAnimState;
}
There was also a "handle" function-member, which took care of all movement and collisions for the player:
#include "player.h"
void Player::handle()
{
if(/*Player presses 'D' key*/)
{
m_x++;
playerAnimState = RUNNING;
} //Other stuff that is just there to look nice
Through lots of experimentation with "//" and "/**/", I've found that I consistently get an error at "playerAnimState = RUNNING." Have I broken some enumeration rule? Does my laptop really suck that bad? I hate to post a "fix my code for me" question, but I'm not very seasoned with enums.
© Game Development or respective owner