MainChar = new CCharacter(96, 96, 60, 15, 15, 10, 0, 0, 5, "Knight.png");Enemies.push_back(CCharacter(96, 96, 60, 15, 15, 10, 0, 0, 5, "Knight.png"));
The problem, however, is that the program fails to load the animation for the enemy class, which comes up as an error during the rendering phase.
I also went through and debugged the code, and it seems like the enemy initializes all of the animations correctly (WalkLeft, WalkRight, PauseLeft, PauseRight), but gets a bad pointer for the current animation, while MainChar didn't:
void CAnimatedSprite::PlayAnimation(const std::string &strAnimName){ m_iterCurrentAnim = m_mapAnimations.find(strAnimName); if (m_iterCurrentAnim == m_mapAnimations.end()) { std::string strError = "Unable to play: " + strAnimName; strError += ". Animation not found."; throw CException(strError); }}
Nothing is different supposedly between the two classes, so why does the MainChar sprite work while the enemy sprite gets a bad pointer? Is it impossible to make a vector work in this scenario or something(?), and if so, what would be a good substitute?