SFML community forums
Help => General => Topic started by: firepro20 on November 21, 2019, 02:44:31 pm
-
I am getting the following error when running the program, violation thrown near default constructor of enemy -
Exception thrown at 0x77C76015 (ntdll.dll) in SFML.exe: 0xC0000005: Access violation writing location 0x00000004.
This is the constructor -
// Default Constructor
Enemy::Enemy()
{
//set alive
mIsAlive = true;
//set speed
enemySpeed = 10.f;
// Load an enemy texture
if (!mEnemyTexture.loadFromFile("Media/Textures/PixelSpaceships/red_01.png")) {
// Handle loading error
std::cout << "Oh No! File not loaded." << std::endl;
}
//scale sprite and set texture so we know size
enemySprite.setTexture(mEnemyTexture);
}
From game.cpp I am calling enemyLoader to instantiate enemy. Array of Enemy is in game.cpp as well
// Enemy
Enemy alienArray[NUMBER_OF_ALIENS];
// Loading Enemy
enemy.enemyLoader(NUMBER_OF_ALIENS, alienArray);
What can I provide to help in identifying what is causing the issue?
-
The issue was resolved by changing the code structure completely in order to avoid calling private methods from public scope. This can be closed.