SFML community forums
Help => General => Topic started by: help me on June 25, 2020, 09:32:10 pm
-
I was planning to make a control multiple sprites game and I know it is risky but I'm risking anyways. So I made the player class in the game.cpp an array and all goes well until an exception is thrown:
Exception thrown at 0x7922CF29 (sfml-graphics-d-2.dll) in sim.exe: 0xC0000005: Access violation reading location 0x00000008.
to
target.draw(this->sprite);
in
void Plane::render(RenderTarget& target)
{
//target.draw(this->sprite);
}
and if I put the array out of the equation it works as normal. What to do??
and btw if I comment the one that got thrown exception it sort of worked, it ran but it was thrown exception sim.exe has triggered a break point
ps. idk how to insert image I'm 100% new I'm so sorry
-
It's triggering a breakpoint? Did you set one?
More information about this would be helpful.
Are you storing a texture with in that class?
If the array is the problem, what sort of array are you using? Do you mean a C array, an std::array or maybe std::vector?
One thing to note is that some containers (for example, vector) can relocate when re-sized. If your texture is contained within the class and it relocates that instance, the sprite's pointer to the texture is invalid and can cause these sorts of problems.
That was a speculation based on commonly-seen mistakes.
-
Based on the address, it looks like you're dereferencing a null pointer.
Also read this post (https://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368) and follow the instructions.
-
Duplicate post: https://en.sfml-dev.org/forums/index.php?topic=27358.0