Feb 1, 2010 at 12:50pm UTC
Hello everyone!
Right now im programming on a little spaceshooter. Every time the player shoots a sprite should be generated from the same image. But my compiler keeps telling me that: main.cpp:166: error: expected primary-expression before "Shot"
Here is part of the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
sf::Image IShot;
if (!IShot.LoadFromFile("Shot.png" )) {
// Error...
}
std::vector<sf::Sprite> ShotVector;
Gameloop:
// SHOOTING
shotTimer++;
if (Game.GetInput().IsKeyDown(sf::Key::N) && shotTimer > 60) {
shotTimer = 0;
shot = true ;
}
if (shot) {
shot = false ;
sf::Sprite Shot;
Shot.SetImage(IRocketP1);
Shot.SetColor(sf::Color(255, 255, 255, 255));
Shot.SetPosition(350.f, 600.f);
Shot.SetCenter(Shot.GetSize().x / 2, Shot.GetSize().y / 2);
ShotVector.push_back(Shot);
}
int i = 0;
for (i = 0; i < ShotVector.size(); i++) {
Game.Draw(ShotVector[i]);
}
Last edited on Feb 1, 2010 at 1:01pm UTC
Feb 1, 2010 at 3:26pm UTC
ooooops found my mistake. i loaded the wrong image into the sprite.
thanks for participating.