C++ 播放器精灵未显示在窗口中

C++ 播放器精灵未显示在窗口中,c++,sfml,C++,Sfml,我一直在尝试使用SFML和C++在VisualStudio中创建精灵,代码本身运行良好,似乎没有错误。 PLAYER.H #pragma once #include "pSprite.h" #include "Sprite.h" #include "Enemy.h" #include "Input.h" #include <Windows.h> class Player : public pSprite { public: Input input; Player(const sf:

我一直在尝试使用SFML和C++在VisualStudio中创建精灵,代码本身运行良好,似乎没有错误。 PLAYER.H

#pragma once
#include "pSprite.h"
#include "Sprite.h"
#include "Enemy.h"
#include "Input.h"
#include <Windows.h>

class Player : public pSprite
{
public:
Input input;
Player(const sf::Vector2f & size = sf::Vector2f(0, 0));
~Player();

pSprite playerSprite;
sf::Texture texture;

float playerWidth;
float playerHeight;
float playerSpeed;

void update(float dt);
void initPlayer(float x, float y);
void kill(); // set to gameover
bool isAlive();
void move();

sf::Vector2f position;
下面是加载纹理并设置精灵的函数的代码


initPlayer在主函数中被调用,应将其设置为可用于主函数中调用的所有其他函数以及绘图和显示。

播放器的首字母x和y是什么?将代码作为文本而不是代码图片发布。Thx.另外,你知道你需要在每一帧显式地显示精灵吗?@litelite是的,这就是主画面中应该发生的事情,初始的x和y是(400500),窗口是(800600),所以在主画面中你调用类似于
player.playerSprite.draw的东西?
void Player::initPlayer(float x, float y)
{
position.x = x;
position.y = y;

playerWidth = 60;
playerHeight = 50;

texture.loadFromFile("player1.png");
playerSprite.setTexture(&texture);
playerSprite.setSize(sf::Vector2f(playerWidth, playerHeight));

playerSpeed = 10;

playerSprite.setPosition(position);
}