I have the following files:
Source.cpp
#include "SpriteControl.h"
#include "SFML\Graphics.hpp"
using namespace sf;
int main(int argc, char ** argv){...}
SpriteControl.cpp
#include "SpriteControl.h"
#include "SFML\Graphics.hpp"
using namespace sf;
SpriteControl::SpriteControl(){}
SpriteControl::SpriteControl(Texture textureIn){
texture = textureIn;}
SpriteControl::~SpriteControl(){}
void SpriteControl::setMoveable(bool in) {
isMoveable = in;}
void SpriteControl::setVelocity(float vx, float vy) {
if (isMoveable) {
velocity.x = vx;
velocity.y = vy;
}
}
Vector2f SpriteControl::getVelocity() {
return velocity;}
SpriteControl.h
#pragma once
class SpriteControl{
Texture texture;
Sprite sprite;
bool isMoveable;
Vector2f velocity;
public:
SpriteControl();
SpriteControl(Texture textureIn);
~SpriteControl();
Vector2f getVelocity();
void setMoveable(bool in);
void setVelocity(float vx, float vy);
};
When I try to build, I get undeclared identifier errors for "texture" and "velocity", as well as "overloaded member function not found" for my constructor, "left of .x must have class/struct/union", "getVelocity is not a member of SpriteControl", and so on. An error for almost every line of both the SpriteControl.cpp and SpriteControl.h files, none of which make any sense. Any thoughts?
Note: the SFML libraries have all be linked properly. Earlier, simpler versions of the program without any header files compiled and ran just fine.
Aucun commentaire:
Enregistrer un commentaire