Here you go:
class Entity{
public:
sf::Sprite mySprite;
sf::Image *myImage;
std::vector<sf::IntRect> &frames;
sf::RenderWindow &myApp;
Vector2 dir;
float speed;
public:
Entity(sf::RenderWindow &app, sf::Image &myImage, std::vector<sf::IntRect> &framesVec, float x, float y, float dirx = 0.0f, float diry = 0.0f)
: myApp(app), frames(framesVec), myImage(&myImage)
{
dir.setXY(dirx,diry);
mySprite.SetImage(myImage);
mySprite.SetPosition(x,y);
}
void update(float delta){
}
void draw(){
myApp.Draw(mySprite);
}
};
std::vector<Projectile*> entities;
void AddEntity(Projectile *ent){
entities.push_back(ent);
}
class Projectile: public Entity{
public:
Direction direction;
Animator myAnimator;
Projectile(sf::RenderWindow &app, sf::Image *myImage, std::vector<sf::IntRect> &framesVec, float x, float y, Direction DIR)
: Entity(app, *myImage, framesVec, x, y) {
speed = 10.0f;
if (DIR == RIGHT)
dir.setXY(speed,0);
else
dir.setXY(-speed,0);
myAnimator.AddNewSequence("start", 0, 0);
myAnimator.AddNewSequence("fly", 1, 3);
myAnimator.PlayAnimation("start","fly");
mySprite.SetSubRect(frames[myAnimator.UpdateAndGetFrame(.0001)]);
AddEntity(this);
}
...
class Character: public Entity{
public:
bool moving;
Direction direction;
const float speed;
const float jumpSpeed;
bool shooting;
bool falling;
bool jumping;
int jumpStartHeight;
int fallStartHeight;
int maxJumpHeight;
Animator myAnimator;
Character(sf::RenderWindow &app, sf::Image &myImage, std::vector<sf::IntRect> &framesVec, float x, float y, float dirx = 0.0f, float diry = 0.0f)
: Entity(app, myImage, framesVec, x, y, dirx, diry, maskr, maskg, maskb), speed(120.0f), jumpSpeed(370.0f), maxJumpHeight(140)
...
Character::Shoot(){
Projectile FIRE(myApp, myImage, LoadProjectileFrames(), mySprite.GetPosition().x, mySprite.GetPosition().y, direction);
}
When the new Projectile's Draw() is called, it stops, throws the above error, and doesn't remember anything about the Entity. I am sure the problem is something stupid, but I can't seem to find the problem.