0

我得到了 .cpp 和头文件,但我得到了这个错误,无法弄清楚它是什么。

我记得在标题结尾的 endif

和 }; 作为一个更接近班级

和 #endif 之后的空行

无法弄清楚出了什么问题。感谢您的回答

头文件:

#ifndef playerreceiver_h
#define playerreceiver_h

#include "Client.h"
#include <SFML\Graphics.hpp>
#include <SFML\Network.hpp>
#include "ClientGameFrame.h"
#include "Packets.h"
#include <string>
#include <iostream>

class PlayerReceiver{
public:
    PlayerReceiver(int id, std::string name, ClientGameFrame * clientGameFrame);
    void recievePackets(sf::Packet &p1);
    void draw(sf::RenderWindow & rw);


    ClientGameFrame * clientGameFrame;
    int id,x, y, hp,energy;
    std::string name;
    double angle;
    Output o;


    sf::Sprite sprite;
};

#endif

和 cpp 文件:

#include "PlayerReceiver.h"



PlayerReceiver::PlayerReceiver(int id, std::string name,  ClientGameFrame * clientGameFrame){
    this->id=id;
    this->name=name;
    this->clientGameFrame=clientGameFrame;
    x=0;
    y=0;
    hp=100;
    energy=100;
}

void PlayerReceiver::draw(sf::RenderWindow & rw){
    rw.draw(sprite);
}

void PlayerReceiver::recievePackets(sf::Packet &p1){

    if(checkPacket(p1,output)){
        p1>>o;
        if(o.id==id){
            angle=o.angle;
            x=o.x;
            y=o.y;
            //sprite.setPosition(x, y);
        }
    }
}


//asda
4

0 回答 0