Hi, I'm struggling with a compile-time error that tells me there's a syntax error with an identifier. It doesn't only appear with 'Ball', but also with other identifiers. I restarted my PC and VS already, but it still doesn't work. I'm already trying to fix it for a week.
//Blocks.h
#pragma once
#include <SFML/Graphics.hpp>
#include "Ball.h"
#include "Variables.h"
class Blocks
{
private:
sf::RectangleShape blocks[16];
public:
Blocks();
sf::RectangleShape getShape(int i);
bool checkCollision(Ball &ball); // syntax error: identifier 'Ball'
void draw(sf::RenderWindow &window);
};
//////////////////////////////////////////////////////////////
//Function checkCollision in Blocks.cpp
bool Blocks::checkCollision(Ball &ball)
{
for (int i = 0; i < 16; i++)
{
if (ball.getShape().getGlobalBounds().intersects(blocks[i].getGlobalBounds()))
{
blocks[i].setPosition(-100.f, -100.f);
return true;
}
}
return false;
}
//////////////////////////////////////////////////////////////
//Function call in Game.cpp
if (blocks->checkCollision(*ball)) // 'Blocks::checkCollision': function does not take 1 arguments
{
ball->moveAfterCollision();
}
There's no error with the definition of checkCollision(*ball) in Blocks.cpp, only with the declaration in Blocks.h.
ball->moveAfterCollision(); doesn't cause the problem too.